plot.Score: Prediction performance

View source: R/postsurvplots.R

plot.ScoreR Documentation

Prediction performance

Description

Plots predictive performance of glmnet in survival analysis in comparison to other models. It uses risk scoring from Score. This extension allows glmnet to support performance measure scoring by R package pec. See examples.

Usage

## S3 method for class 'Score'
plot(x, ..., type = c("roc", "auc", "brier"), pos = 0.3)

Arguments

x

Score object. See examples.

...

for future implementations.

type

metric to return. Choices are "roc", "auc", "brier".

pos

spacing between the lines.

Details

Implements plot method for Score for time-dependent Brier score, AUC and ROC. However, currently, no support for time-dependent covariate models.

Value

a ggplot object.

Examples


data(veteran, package="survival")
# glmnet
gfit1 <- glmnetsurv(Surv(time, status) ~ factor(trt) + karno + diagtime + age + prior
	, data = veteran
	, lambda = 0.02
	, alpha = 0.8
)

# coxph
cfit1 <- coxph(Surv(time, status) ~ factor(trt) + karno + diagtime + age + prior
	, data = veteran
	, method = "breslow"
	, x = TRUE
	, y = TRUE
)

# Evaluate model performance at 90, 180, 365 time points
score_obj <- Score(list("coxph" = cfit1, "glmnet" = gfit1)
	, Surv(time, status) ~ 1
	, data = veteran
	, plots = "roc"
	, metrics = c("auc", "brier")
	, B = 10
	, times = c(90, 180, 365)
)

# Plot AUC
plot(score_obj, type = "auc")
# Plot ROC
plot(score_obj, type = "roc")
# Plot brier
plot(score_obj, type = "brier")

# Prediction error using pec package
## Not run: 
	if (require("pec")) {
		pec_fit <- pec(list("coxph" = cfit1, "glmnet" = gfit1)
			, Surv(time, status) ~ 1
			, data = veteran
			, splitMethod = "Boot632plus"
			, keep.matrix = TRUE
		)
		plot(pec_fit)
	}

## End(Not run)


CYGUBICKO/glmnetpostsurv documentation built on Sept. 1, 2022, 7:26 p.m.