I want to do a Cox PH model accommodates time-varying covariates. I learnt that I need to use tmerge() to transform the data into the start-stop format. But there is considerable missingness in baseline comorbidity score. Therefore, I used multiple imputation with mice() to impute this missing value. After MI, I am left with a multiply imputed data in mids format. I tried to use tmerge() within with() to try to transform each imputed dataset separately, which then generated a mira format output. But I don’t know how to display and check the transformed data in mira format, before I can do cox regression as the next step.
Example is below. Looking forward to any help!
data <- data.frame(id = c(1,2,3,4,5,6),v=c(0,1,1,0,1,1),v_time=c(10,15,20,20,14,8),comorbidity=c(10,2,NA,1,2,NA),overall_survival=c(90,80,30,50,40,88))
library(mice)
imputed <- mice(data,seed=3) #imputed is in mids format
library(survival)
impute_trans<- with(imputed,tmerge(data1=imputed$data[,-3],
data2=imputed$data,
id=id,
tstop=overall_survival))
(Multiple subsequent tmerge() runs omitted for simplicity.)
#impute_trans is in mira format. There is no error message. But how to check the transformed datasets please?
Julie Yanan Zhu is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.