View source: R/predict.CauseSpecificCox.R
predict.CauseSpecificCox | R Documentation |
Apply formula to combine two or more Cox models into absolute risk (cumulative incidence function).
## S3 method for class 'CauseSpecificCox'
predict(
object,
newdata,
times,
cause,
type = "absRisk",
landmark = NA,
keep.times = 1L,
keep.newdata = 1L,
keep.strata = 1L,
se = FALSE,
band = FALSE,
iid = FALSE,
confint = (se + band) > 0,
average.iid = FALSE,
product.limit = TRUE,
store.iid = "full",
diag = FALSE,
max.time = NULL,
...
)
object |
The fitted cause specific Cox model |
newdata |
[data.frame or data.table] Contain the values of the predictor variables
defining subject specific predictions relative to each cause.
Should have the same structure as the data set used to fit the |
times |
[numeric vector] Time points at which to return the estimated absolute risk. |
cause |
[integer/character] Identifies the cause of interest among the competing events. |
type |
[character] Can be changed to |
landmark |
[integer] The starting time for the computation of the cumulative risk. |
keep.times |
[logical] If |
keep.newdata |
[logical] If |
keep.strata |
[logical] If |
se |
[logical] If |
band |
[logical] If |
iid |
[logical] If |
confint |
[logical] If |
average.iid |
[logical]. If |
product.limit |
[logical]. If |
store.iid |
[character] Implementation used to estimate the influence function and the standard error.
Can be |
diag |
[logical] when |
max.time |
[numeric] maximum time of the response of the fitted data. Only relevant if
model |
... |
not used. |
This function computes the absolute risk as given by formula 2 of (Ozenne et al., 2017). Confidence intervals and confidence bands can be computed using a first order von Mises expansion. See the section "Construction of the confidence intervals" in (Ozenne et al., 2017).
A detailed explanation about the meaning of the argument store.iid
can be found
in (Ozenne et al., 2017) Appendix B "Saving the influence functions".
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.
The iid decomposition is output using an array containing the value of the influence of each subject used to fit the object (dim 1), for each subject in newdata (dim 3), and each time (dim 2).
Brice Ozenne broz@sund.ku.dk, Thomas A. Gerds tag@biostat.ku.dk
Brice Ozenne, Anne Lyngholm Sorensen, Thomas Scheike, Christian Torp-Pedersen and Thomas Alexander Gerds. riskRegression: Predicting the Risk of an Event using Cox Regression Models. The R Journal (2017) 9:2, pages 440-460.
confint.predictCSC
to compute confidence intervals/bands.
autoplot.predictCSC
to display the predictions.
library(survival)
library(prodlim)
#### generate data ####
set.seed(5)
d <- sampleData(80,outcome="comp") ## training dataset
nd <- sampleData(4,outcome="comp") ## validation dataset
d$time <- round(d$time,1) ## create tied events
ttt <- sort(sample(x = unique(d$time), size = 10))
## estimate a CSC model based on the coxph function
CSC.fit <- CSC(Hist(time,event)~ X3+X8, data=d, method = "breslow")
## compute the absolute risk of cause 1, in the validation dataset
## at time 1:10
CSC.risk <- predict(CSC.fit, newdata=nd, times=1:10, cause=1)
CSC.risk
## compute absolute risks with CI for cause 2
## (without displaying the value of the covariates)
predict(CSC.fit,newdata=nd,times=1:10,cause=2,se=TRUE,
keep.newdata = FALSE)
## other example
library(survival)
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) ## note: absRisk>1 due to small number of observations
## using the cph function instead of coxph
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
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.