predictRisk.glmnetsurv: Extract predictions from glmnet model

View source: R/glmnetsurvfit.R

predictRisk.glmnetsurvR Documentation

Extract predictions from glmnet model

Description

Extract event probabilities from the fitted model.

Usage

## S3 method for class 'glmnetsurv'
predictRisk(object, newdata, times, ...)

Arguments

object

fitted glmnetsurv.

newdata

a matrix containing the variables appearing in model glmnetsurv formula.

times

a vector of times in the range of the response, at which to return the survival probabilities.

...

for future implementations.

Details

For survival outcome, the function predicts the risk, 1 - S(t|x), where S(t|x) is the survival chance of an individual characterized by x.

Value

a matrix of probabilities with as many rows as the rows of the newdata and as many columns as number of time points (times).

Examples


data(veteran, package="survival")
# Penalized
lam <- 0.02
alp <- 1
gfit1 <- glmnetsurv(Surv(time, status) ~ factor(trt) + karno + diagtime + age + prior
	, data = veteran
	, alpha = alp
	, lambda = lam
)
r1 <- predictRisk(gfit1, newdata = veteran[1:80,], times = 10)

# Unpenalized model
lam2 <- 0
alp2 <- 1
gfit2 <- glmnetsurv(Surv(time, status) ~ factor(trt) + karno + diagtime + age + prior
	, data = veteran
	, alpha = alp2
	, lambda = lam2
)
r2 <- predictRisk(gfit2, newdata = veteran[1:80,], times = 10)
plot(r1, r2, xlim=c(0,1), ylim=c(0,1)
	, xlab = "Penalized predicted survival chance at 10"
	, ylab="Unpenalized predicted survival chance at 10"
)


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