Learn R Programming

riskRegression (version 2018.04.21)

predictCoxPL: Computation of survival probabilities from Cox regression models using the product limit estimator.

Description

Same as predictCox except that the survival is estimated using the product limit estimator.

Usage

predictCoxPL(object, newdata, times, type = c("cumhazard", "survival"),
  se = FALSE, band = FALSE, ...)

Arguments

object

The fitted Cox regression model object either obtained with coxph (survival package) or cph (rms package).

newdata

A data.frame or data.table containing the values of the predictor variables defining subject specific predictions. Should have the same structure as the data set used to fit the object.

times

Time points at which to evaluate the predictions.

type

the type of predicted value. Choices are "hazard", "cumhazard", and "survival". See predictCox for more details.

se

Logical. If TRUE add the standard error to the output.

band

Logical. If TRUE add the confidence band to the output.

...

additional arguments to be passed to predictCox.

Examples

Run this code
# NOT RUN {
library(survival)

set.seed(10)
d <- sampleData(40,outcome="survival")
nd <- sampleData(4,outcome="survival")
d$time <- round(d$time,1)
fit <- coxph(Surv(time,event)~X1 + strata(X2) + X6,
             data=d, ties="breslow", x = TRUE, y = TRUE)
predictCoxPL(fit, newdata = d, times = 1:5)
fit <- coxph(Surv(time,event)~X1 + X2 + X6,
             data=d, ties="breslow", x = TRUE, y = TRUE)
predictCoxPL(fit, newdata = d, times = 1:5)


#### Compare exp to product limit
set.seed(10)
A <- predictCoxPL(fit, newdata = d[1:5], times = 1:5, se = TRUE, band = TRUE, log.transform = FALSE)
set.seed(10)
B <- predictCox(fit, newdata = d[1:5], times = 1:5, se = TRUE, band = TRUE, log.transform = FALSE)

A$survival - B$survival
A$survival.lower - B$survival.lower
A$survival.upper - B$survival.upper
A$survival.lowerBand - B$survival.lowerBand
A$survival.upperBand - B$survival.upperBand
# }

Run the code above in your browser using DataLab