1
$\begingroup$

I am building 2 cox models:

  • Without time-dependent covariates
  • With time-dependent covariates.

1.The first model (without time-dependent variables) as specified below in R works fine and I have no problem with it:

library(rms)
formula_m1 <- (Surv(time=FOLLOWUP ,event=OUTCOME) ~ COVAR1 + COVAR2 + COVAR3 )
//I have split my data into training and testing sets beforehand
stat.train.m <- parlmice(missing_train_data,n.core =  6 , n.imp.core = 1,printFlag=TRUE)
stat.test.m <- complete(mice(missing_test_data, m=2,maxit = 2,printFlag = FALSE),1)

//train the model
cphfit.m<-fit.mult.impute(formula=formula_m1,fitter=cph,surv=TRUE,x=TRUE,y=TRUE,xtrans=stat.train.m,pr=FALSE)
summary(cphfit.m)

//Create survival estimates for each failure time on test data 
survest.m<-survest(cphfit.m, newdata=stat.test.m, times=c(1,2,3,4,5,6,7,8,9,10))
//produce calibrate plots for each failure time
for( i in 1:10){
  survest.m_surv<-survest.m$surv[,i]
  calibrate.m <- calibrate(cphfit.m,pred=survest.m_surv,u=i,cmethod='hare',B=20)
  print(plot(calibrate.m))
}

// produce C-index using Rcorr.cens for my test data and hence validate the trained model
surv.obj.m<-with(stat.test.m,Surv(FOLLOWUP,EVEROUTCOME_1))
valid.test.m<-rcorr.cens(x=survest.m$surv[,10], S=surv.obj.m)

2.The following is my time-dependent model and my problem is that I am stuck with not being able to validate and calibrate the time-dependent covariates model:

...
formula_td <- (Surv(time=START, time2=END ,event=STATUS) ~ COVAR1 + COVAR2 + COVAR3 )
//I have split my data into training and testing sets beforehand
td.train <- parlmice(missing_td_train_data,n.core =  6 , n.imp.core = 1,printFlag=TRUE)
td.test <- complete(mice(missing_td_test_data, m=2,maxit = 2,printFlag = FALSE),1)

//fit the model
td.cphfit<-fit.mult.impute(formula=formula_td,fitter=cph,surv=TRUE,x=TRUE,y=TRUE,xtrans=td.train,pr=FALSE)
summary(td.cphfit)

//Create survival estimates for each failure time on test data 
td.survest<-survest(td.cphfit, newdata=td.test, times=c(1,2,3,4,5,6,7,8,9,10))
td.surv.obj<-with(td.test,Surv(FOLLOWUP,EVEROUTCOME_1))

//How to calibrate my model for each failure time and plot it?
??calibrate(td.cphfit)??

//How to produce C-index for my test data and hence validate the trained model?
??rcorr.cens(x=td.survest$surv[,10], S=td.surv.obj)??

I don't think rms.calibrate and rcorr.cens functions work on time-dependent cox models out of the box. Does anyone know how to do it? What's my alternative?

Any help will be deeply appreciated!

Thank you

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.