Learn R Programming

pec (version 2.0.8)

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'. The function predictSurvProb is a generic function that means it invokes specifically designed functions depending on the 'class' of the first argument.

Usage

predictSurvProb(object, newdata, times, ...)
## S3 method for class 'aalen':
predictSurvProb(object, newdata, times,...)
## S3 method for class 'cox.aalen':
predictSurvProb(object, newdata, times,...)
## S3 method for class 'coxph':
predictSurvProb(object, newdata, times,...)
## S3 method for class 'cph':
predictSurvProb(object, newdata, times,...)
## S3 method for class 'default':
predictSurvProb(object, newdata, times,...)
## S3 method for class 'rsf':
predictSurvProb(object, newdata, times,...)
## S3 method for class 'matrix':
predictSurvProb(object, newdata, times,...)
## S3 method for class 'mfp':
predictSurvProb(object, newdata, times,...)
## S3 method for class 'pecCforest':
predictSurvProb(object, newdata, times,...)
## S3 method for class 'prodlim':
predictSurvProb(object, newdata, times,...)
## S3 method for class 'psm':
predictSurvProb(object, newdata, times,...)
## S3 method for class 'selectCox':
predictSurvProb(object, newdata, times,...)
## S3 method for class 'survfit':
predictSurvProb(object, newdata, times,...)
## S3 method for class 'phnnet':
predictSurvProb(object, newdata, times,train.data,...)
## S3 method for class 'survnnet':
predictSurvProb(object, newdata, times,train.data,...)
## S3 method for class 'rpart':
predictSurvProb(object, newdata, times,train.data,...)

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.
train.data
An optional data frame which contains the response and predictor variable combinations in which the prediction model was trained
...
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 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), mfp (library mfp), phnnet (library survnnet), survnnet (library survnnet), rpart (library rpart), product.limit (library prodlim), survfit (library survival), psm (library rms)

See Also

predict,survfit

Examples

Run this code
# generate some survival data
d <- SimSurv(100)
# then fit a Cox model 
coxmodel <- cph(Surv(time,status)~X1+X2,data=d,surv=TRUE)

# predicted survival probabilities can be extracted
# 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)

# the same can be done e.g. for a randomSurvivalForest model
library(randomSurvivalForest)
rsfmodel <- rsf(Survrsf(time,status)~X1+X2,data=d)
predictSurvProb(rsfmodel,newdata=ndat,times=ttt)

Run the code above in your browser using DataLab