Learn R Programming

riskRegression (version 1.4.3)

predict.CauseSpecificCox: Predicting absolute risk from cause-specific Cox models

Description

Apply formula to combine two or more Cox models into absolute risk (cumulative incidence function)

Usage

# S3 method for CauseSpecificCox
predict(object, newdata, times, cause,
  landmark = NA, keep.times = 1L, keep.newdata = 1L, keep.strata = 1L,
  se = FALSE, band = FALSE, iid = FALSE, average.iid = FALSE,
  nSim.band = 10000, logTransform = FALSE, productLimit = TRUE,
  conf.level = 0.95, store.iid = "full", ...)

Arguments

object

The fitted cause specific Cox model

newdata

A data frame containing the values of the variables in the right hand side of 'coxph' for each subject.

times

Vector of times at which to return the estimated absolute risk.

cause

Identifies the cause of interest among the competing events.

landmark

the starting time for the computation of the cumulative risk

keep.times

Logical. If TRUE add the evaluation times to the output.

keep.newdata

Logical. If TRUE add the value of the covariates used to make the prediction in the output list.

keep.strata

Logical. If TRUE add the value of the strata used to make the prediction in the output list.

se

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

band

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

iid

Logical. If TRUE add the influence function to the output.

average.iid

Logical. If TRUE add the average of the influence function over newdata to the output.

nSim.band

the number of simulations used to compute the quantiles for the confidence bands.

logTransform

Should the confidence intervals/bands be computed on the log(-log) scale and be backtransformed. Otherwise they are computed on the original scale and truncated (if necessary).

productLimit

Logical. If true the survival is computed using the product limit estimator. Otherwise the exponential approximation is used (i.e. exp(-cumulative hazard)).

conf.level

Level of confidence.

store.iid

Implementation used to estimate the influence function and the standard error. Can be "full" or "minimal". See the details section of calcSeCSC.

...

not used

Value

A list containing:

  • absRisk: (data table) the predictions for each subject (in rows) and each time (in columns).

  • absRisk.se: (data table) the standard errors of the predictions.

  • (absRisk.iid): (array) the value of the influence of each subject used to fit the object (dim 3) for each subject in newdata (dim 1) and each time (dim 2).

  • times: (vector) the evaluation times.

Details

Note: for Cox regression models with time varying covariates it does not make sense to use this function, because the predicted risk has to be a measurable function of the data available at the time origin.

When setting logTransform to TRUE, the standard error that is returned is before back-transformation to the original scale.

Examples

Run this code
# NOT RUN {
set.seed(5)
d <- sampleData(80,outcome="comp")
nd <- sampleData(4,outcome="comp")
d$time <- round(d$time,1)
ttt <- sort(sample(x = unique(d$time), size = 10))

# coxph function
CSC.fit <- CSC(Hist(time,event)~ X3+X8,data=d, method = "breslow")
x= predict(CSC.fit,newdata=nd,times=1:10,cause=1,se=1L)
px=print(x)
px
x2 = predict(CSC.fit,newdata=nd,times=1:10,cause=1,se=1L,
           logTransform = TRUE)

predCSC <- predict(CSC.fit, newdata = d, cause = 2, times = ttt)
predCSC.se <- predict(CSC.fit, newdata = d[1:5,], cause = 2, times = ttt,
                      se = TRUE,keep.newdata=TRUE)
predCSC.iid <- predict(CSC.fit, newdata = d[1:5,],
                       cause = 2, times = ttt, iid = TRUE)

# predCSC.se$absRisk.se
# sqrt(apply(predCSC.iid$absRisk.iid[,1,]^2,1,function(x){sum(x)}))
## strata
CSC.fit.s <- CSC(list(Hist(time,event)~ strata(X1)+X2+X9,
 Hist(time,event)~ X2+strata(X4)+X8+X7),data=d, method = "breslow")
predict(CSC.fit.s,cause=1,times=ttt,se=1L)
# cph function
CSC.cph <- CSC(Hist(time,event)~ X1+X2,data=d, method = "breslow", fitter = "cph")

predict(CSC.cph, newdata = d, cause = 2, times = ttt)

# landmark analysis
T0 <- 1
predCSC_afterT0 <- predict(CSC.fit, newdata = d, cause = 2, times = ttt[ttt>T0], landmark = T0)
predCSC_afterT0

# }

Run the code above in your browser using DataLab