Learn R Programming

dynpred (version 0.1.2)

pew: Calculate dynamic prediction error curve

Description

Calculate dynamic fixed width prediction error curve.

Usage

pew(time, status, tsurv, survmat, tcens, censmat, width, FUN = c("KL", "Brier"), tout)
pewcox(formula, censformula, width, data, censdata, FUN = c("KL", "Brier"), tout, CV = FALSE, progress = FALSE)

Arguments

time
Vector of time points in data
status
Vector of event indicators in data
tsurv
Vector of time points corresponding to the estimated survival probabilities in survmat
survmat
Matrix of estimated survival probabilities; dimension should be length of tsurv x length of time
tcens
Vector of time points corresponding to the estimated censoring probabilities in censmat
censmat
Matrix of estimated censoring probabilities; dimension should be length of tcens x length of time
width
Width of the window
FUN
The error function, either "KL" (default) for Kullback-Leibler or "Brier" for Brier score
tout
Vector of time points at which to evaluate prediction error. If missing, prediction error will be evaluated at all time points where the estimate will change value
formula
Formula for prediction model to be used as in coxph
censformula
Formula for censoring model, also to be used as in coxph
data
Data set in which to interpret formula
censdata
Data set in which to interpret censformula
CV
Boolean (default=FALSE); if TRUE, (leave-one-out) cross-validation is used for the survival probabilities
progress
Boolean (default=FALSE); if TRUE, progress is printed on screen

Value

A data frame with columns
time
Event time points
Err
Prediction error of model specified by formula at these time points
and with attribute "width" given as input.

Details

Corresponds to Equation (3.6) in van Houwelingen and Putter (2011). The censformula is used to calculate inverse probability of censoring weights (IPCW).

References

van Houwelingen HC, Putter H (2012). Dynamic Prediction in Clinical Survival Analysis. Chapman & Hall.

Examples

Run this code
data(ova)
# Example on a subset, because the effect of CV is clearer
ova2 <- ova[1:100,]
pewcox(Surv(tyears, d) ~ Karn + Broders + FIGO + Ascites + Diam, Surv(tyears, 1-d) ~ 1,
  width=2, data = ova2, FUN="Brier", tout=seq(0,6,by=0.5))
pewcox(Surv(tyears, d) ~ Karn + Broders + FIGO + Ascites + Diam, Surv(tyears, 1-d) ~ 1,
  width=2, data = ova2, FUN="Brier", tout=seq(0,6,by=0.5), CV=TRUE, progress=TRUE)


pewcox(Surv(tyears, d) ~ Karn + Broders + FIGO + Ascites + Diam, Surv(tyears, 1-d) ~ 1,
  width=2, data = ova, FUN="Brier", tout=seq(0,6,by=0.5))
pewcox(Surv(tyears, d) ~ Karn + Broders + FIGO + Ascites + Diam, Surv(tyears, 1-d) ~ 1,
  width=2, data = ova, FUN="Brier", tout=seq(0,6,by=0.5), CV=TRUE, progress=TRUE)

Run the code above in your browser using DataLab