pec (version 2018.07.26)

predictSurvProb: Predicting survival probabilities

Description

Function to extract survival probability predictions from various modeling approaches. The most prominent one is the Cox regression model which can be fitted for example with `coxph' and with `cph'.

Usage

# S3 method for aalen
predictSurvProb(object,newdata,times,...)
# S3 method for riskRegression
predictSurvProb(object,newdata,times,...)
# S3 method for cox.aalen
predictSurvProb(object,newdata,times,...)
# S3 method for cph
predictSurvProb(object,newdata,times,...)
# S3 method for coxph
predictSurvProb(object,newdata,times,...)
# S3 method for matrix
predictSurvProb(object,newdata,times,...)
# S3 method for selectCox
predictSurvProb(object,newdata,times,...)
# S3 method for pecCforest
predictSurvProb(object,newdata,times,...)
# S3 method for prodlim
predictSurvProb(object,newdata,times,...)
# S3 method for psm
predictSurvProb(object,newdata,times,...)
# S3 method for survfit
predictSurvProb(object,newdata,times,...)
# S3 method for pecRpart
predictSurvProb(object,newdata,times,...)
#' \method{predictSurvProb}{pecCtree}(object,newdata,times,...)

Arguments

object

A fitted model from which to extract predicted survival probabilities

newdata

A data frame containing predictor variable combinations for which to compute predicted survival probabilities.

times

A vector of times in the range of the response variable, e.g. times when the response is a survival object, at which to return the survival probabilities.

Additional arguments that are passed on to the current method.

Value

A matrix with as many rows as NROW(newdata) and as many columns as length(times). Each entry should be a probability and in rows the values should be decreasing.

Details

The function predictSurvProb is a generic function that means it invokes specifically designed functions depending on the 'class' of the first argument.

The function pec requires survival probabilities for each row in newdata at requested times. These probabilities are extracted from a fitted model of class CLASS with the function predictSurvProb.CLASS.

Currently there are predictSurvProb methods for objects of class cph (library rms), coxph (library survival), aalen (library timereg), cox.aalen (library timereg), rpart (library rpart), product.limit (library prodlim), survfit (library survival), psm (library rms)

References

Ulla B. Mogensen, Hemant Ishwaran, Thomas A. Gerds (2012). Evaluating Random Forests for Survival Analysis Using Prediction Error Curves. Journal of Statistical Software, 50(11), 1-23. URL http://www.jstatsoft.org/v50/i11/.

See Also

predict,survfit

Examples

Run this code
# NOT RUN {
# generate some survival data
library(prodlim)
set.seed(100)
d <- SimSurv(100)
# then fit a Cox model
library(rms)
coxmodel <- cph(Surv(time,status)~X1+X2,data=d,surv=TRUE)

# Extract predicted survival probabilities 
# at selected time-points:
ttt <- quantile(d$time)
# for selected predictor values:
ndat <- data.frame(X1=c(0.25,0.25,-0.05,0.05),X2=c(0,1,0,1))
# as follows
predictSurvProb(coxmodel,newdata=ndat,times=ttt)

# stratified cox model
sfit <- coxph(Surv(time,status)~strata(X1)+X2,data=d,,x=TRUE,y=TRUE)
predictSurvProb(sfit,newdata=d[1:3,],times=c(1,3,5,10))

## simulate some learning and some validation data
learndat <- SimSurv(100)
valdat <- SimSurv(100)
## use the learning data to fit a Cox model
library(survival)
fitCox <- coxph(Surv(time,status)~X1+X2,data=learndat,x=TRUE,y=TRUE)
## suppose we want to predict the survival probabilities for all patients
## in the validation data at the following time points:
## 0, 12, 24, 36, 48, 60
psurv <- predictSurvProb(fitCox,newdata=valdat,times=seq(0,60,12))
## This is a matrix with survival probabilities
## one column for each of the 5 time points
## one row for each validation set individual

# Do the same for a randomSurvivalForest model
library(randomForestSRC)
rsfmodel <- rfsrc(Surv(time,status)~X1+X2,data=d)
predictSurvProb(rsfmodel,newdata=ndat,times=ttt)

## Cox with ridge option
f1 <- coxph(Surv(time,status)~X1+X2,data=learndat,x=TRUE,y=TRUE)
f2 <- coxph(Surv(time,status)~ridge(X1)+ridge(X2),data=learndat,x=TRUE,y=TRUE)
plot(predictSurvProb(f1,newdata=valdat,times=10),
     pec:::predictSurvProb.coxph(f2,newdata=valdat,times=10),
     xlim=c(0,1),
     ylim=c(0,1),
     xlab="Unpenalized predicted survival chance at 10",
     ylab="Ridge predicted survival chance at 10")


# }

Run the code above in your browser using DataLab