cindex | R Documentation |
In survival analysis, a pair of patients is called concordant if the risk of the event predicted by a model is lower for the patient who experiences the event at a later timepoint. The concordance probability (C-index) is the frequency of concordant pairs among all pairs of subjects. It can be used to measure and compare the discriminative power of a risk prediction models. The function provides an inverse of the probability of censoring weigthed estimate of the concordance probability to adjust for right censoring. Cross-validation based on bootstrap resampling or bootstrap subsampling can be applied to assess and compare the discriminative power of various regression modelling strategies on the same set of data.
cindex(
object,
formula,
data,
eval.times,
pred.times,
cause,
lyl = FALSE,
cens.model = "marginal",
ipcw.refit = FALSE,
ipcw.args = NULL,
ipcw.limit,
tiedPredictionsIn = TRUE,
tiedOutcomeIn = TRUE,
tiedMatchIn = TRUE,
splitMethod = "noPlan",
B,
M,
model.args = NULL,
model.parms = NULL,
keep.models = FALSE,
keep.residuals = FALSE,
keep.pvalues = FALSE,
keep.weights = FALSE,
keep.index = FALSE,
keep.matrix = FALSE,
multiSplitTest = FALSE,
testTimes,
confInt = FALSE,
confLevel = 0.95,
verbose = TRUE,
savePath = NULL,
slaveseed = NULL,
na.action = na.fail,
...
)
object |
A named list of prediction models, where allowed entries are
(1) R-objects for which a predictSurvProb method exists (see
details), (2) a |
formula |
A survival formula. The left hand side is used to finde the
status response variable in |
data |
A data frame in which to validate the prediction models and to
fit the censoring model. If |
eval.times |
A vector of timepoints for evaluating the discriminative
ability. At each timepoint the c-index is computed using only those pairs
where one of the event times is known to be earlier than this timepoint. If
|
pred.times |
A vector of timepoints for evaluating the prediction
models. This should either be exactly one timepoint used for all
|
cause |
For competing risks, the event of interest. Defaults to the
first state of the response, which is obtained by evaluating the left hand
side of |
lyl |
If |
cens.model |
Method for estimating inverse probability of censoring weigths:
|
ipcw.refit |
If |
ipcw.args |
List of arguments passed to function specified by argument |
ipcw.limit |
Value between 0 and 1 (but no equal to 0!) used to cut for small weights in order to stabilize the estimate at late times were few individuals are observed. |
tiedPredictionsIn |
If |
tiedOutcomeIn |
If |
tiedMatchIn |
If |
splitMethod |
Defines the internal validation design:
|
B |
Number of bootstrap samples. The default depends on argument
|
M |
The size of the bootstrap samples for resampling without replacement. Ignored for resampling with replacement. |
model.args |
List of extra arguments that can be passed to the
|
model.parms |
Experimental. List of with exactly one entry for each
entry in |
keep.models |
Logical. If |
keep.residuals |
Experimental. |
keep.pvalues |
Experimental. |
keep.weights |
Experimental. |
keep.index |
Logical. If |
keep.matrix |
Logical. If |
multiSplitTest |
Experimental. |
testTimes |
A vector of time points for testing differences between models in the time-point specific Brier scores. |
confInt |
Experimental. |
confLevel |
Experimental. |
verbose |
if |
savePath |
Place in your filesystem (directory) where training models
fitted during cross-validation are saved. If |
slaveseed |
Vector of seeds, as long as |
na.action |
Passed immediately to model.frame. Defaults to na.fail. If set otherwise most prediction models will not work. |
... |
Not used. |
Pairs with identical observed times, where one is uncensored and one is
censored, are always considered usuable (independent of the value of
tiedOutcomeIn
), as it can be assumed that the event occurs at a later
timepoint for the censored observation.
For uncensored response the result equals the one obtained with the
functions rcorr.cens
and rcorrcens
from the Hmisc
package (see examples).
Estimates of the C-index.
Thomas A Gerds tag@biostat.ku.dk
TA Gerds, MW Kattan, M Schumacher, and C Yu. Estimating a time-dependent concordance index for survival prediction models with covariate dependent censoring. Statistics in Medicine, Ahead of print:to appear, 2013. DOI = 10.1002/sim.5681
Wolbers, M and Koller, MT and Witteman, JCM and Gerds, TA (2013) Concordance for prognostic models with competing risks Research report 13/3. Department of Biostatistics, University of Copenhagen
Andersen, PK (2012) A note on the decomposition of number of life years lost according to causes of death Research report 12/2. Department of Biostatistics, University of Copenhagen
Paul Blanche, Michael W Kattan, and Thomas A Gerds. The c-index is not proper for the evaluation of-year predicted risks. Biostatistics, 20(2): 347–357, 2018.
# simulate data based on Weibull regression
library(prodlim)
set.seed(13)
dat <- SimSurv(100)
# fit three different Cox models and a random survival forest
# note: low number of trees for the purpose of illustration
library(survival)
cox12 <- coxph(Surv(time,status)~X1+X2,data=dat,x=TRUE,y=TRUE)
cox1 <- coxph(Surv(time,status)~X1,data=dat,x=TRUE,y=TRUE)
cox2 <- coxph(Surv(time,status)~X2,data=dat,x=TRUE,y=TRUE)
#
# compute the apparent estimate of the C-index at a single time point
#
A1 <- pec::cindex(list("Cox X1"=cox1),
formula=Surv(time,status)~X1+X2,
data=dat,
eval.times=10)
#
# compute the apparent estimate of the C-index at different time points
#
ApparrentCindex <- pec::cindex(list("Cox X1"=cox1,
"Cox X2"=cox2,
"Cox X1+X2"=cox12),
formula=Surv(time,status)~X1+X2,
data=dat,
eval.times=seq(1,15,1))
print(ApparrentCindex)
plot(ApparrentCindex)
#
# compute the bootstrap-crossvalidation estimate of
# the C-index at different time points
#
set.seed(142)
bcvCindex <- pec::cindex(list("Cox X1"=cox1,
"Cox X2"=cox2,
"Cox X1+X2"=cox12),
formula=Surv(time,status)~X1+X2,
data=dat,
splitMethod="bootcv",
B=5,
eval.times=seq(1,15,1))
print(bcvCindex)
plot(bcvCindex)
# for uncensored data the results are the same
# as those obtained with the function rcorr.cens from Hmisc
set.seed(16)
dat <- SimSurv(30)
dat$staus=1
fit12 <- coxph(Surv(time,status)~X1+X2,data=dat,x=TRUE,y=TRUE)
fit1 <- coxph(Surv(time,status)~X1,data=dat,x=TRUE,y=TRUE)
fit2 <- coxph(Surv(time,status)~X2,data=dat,x=TRUE,y=TRUE)
Cpec <- pec::cindex(list("Cox X1+X2"=fit12,"Cox X1"=fit1,"Cox X2"=fit2),
formula=Surv(time,status)~1,
data=dat)
p1 <- predictSurvProb(fit1,newdata=dat,times=10)
p2 <- predictSurvProb(fit2,newdata=dat,times=10)
p12 <- predictSurvProb(fit12,newdata=dat,times=10)
if (requireNamespace("Hmisc",quietly=TRUE)){
library(Hmisc)
harrelC1 <- rcorr.cens(p1,with(dat,Surv(time,status)))
harrelC2 <- rcorr.cens(p2,with(dat,Surv(time,status)))
harrelC12 <- rcorr.cens(p12,with(dat,Surv(time,status)))
harrelC1[["C Index"]]==Cpec$AppCindex[["Cox.X1"]]
harrelC2[["C Index"]]==Cpec$AppCindex[["Cox.X2"]]
harrelC12[["C Index"]]==Cpec$AppCindex[["Cox.X1.X2"]]
}
#
# competing risks
#
library(riskRegression)
library(prodlim)
set.seed(30)
dcr.learn <- SimCompRisk(30)
dcr.val <- SimCompRisk(30)
pec::cindex(CSC(Hist(time,event)~X1+X2,data=dcr.learn),data=dcr.val)
fit <- CSC(Hist(time,event)~X1+X2,data=dcr.learn)
cif <- predictRisk(fit,newdata=dcr.val,times=3,cause=1)
pec::cindex(list(fit),data=dcr.val,times=3)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.