View source: R/glmnetsurvfit.R
predictSurvProb.glmnetsurv | R Documentation |
The function extracts the survival probability predictions from a glmnet
model.
predictSurvProb.glmnetsurv(object, newdata, times, ...)
object |
fitted |
newdata |
a matrix containing the variables appearing in model |
times |
a vector of times in the range of the response, at which to return the survival probabilities. |
... |
for future implementations. |
a matrix of probabilities with as many rows as the rows of the newdata
and as many columns as number of time points (times
).
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" )
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.