predictSurvProb.glmnetsurv: Predict survival probabilities at various time points

View source: R/glmnetsurvfit.R

predictSurvProb.glmnetsurvR Documentation

Predict survival probabilities at various time points

Description

The function extracts the survival probability predictions from a glmnet model.

Usage

predictSurvProb.glmnetsurv(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.

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
)
p1 <- predictSurvProb.glmnetsurv(gfit1, newdata = veteran[1:80,], time = 10)

# Unpenalized model
lam2 <- 0
alp2 <- 1
gfit2 <- glmnetsurv(Surv(time, status) ~ factor(trt) + karno + diagtime + age + prior
	, data = veteran
	, alpha = alp2
	, lambda = lam2
)
p2 <- predictSurvProb.glmnetsurv(gfit2, newdata = veteran[1:80,], times = 10)

plot(p1, p2, 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.