You did what is called
Obvious but wrong approach ...
as indicated in Using time-dependent covariates and time-dependent coefficients in the Cox vignette model in version 2.41-3 R survival package. Instead, you should use the time conversion function, i.e. The tt function, as indicated in the same vignette. The code will look like an example in vignette
> library(survival) > vfit3 <- coxph(Surv(time, status) ~ trt + prior + karno + tt(karno), + data=veteran, + tt = function(x, t, ...) x * log(t+20)) > > vfit3 Call: coxph(formula = Surv(time, status) ~ trt + prior + karno + tt(karno), data = veteran, tt = function(x, t, ...) x * log(t + 20)) coef exp(coef) se(coef) zp trt 0.01648 1.01661 0.19071 0.09 0.9311 prior -0.00932 0.99073 0.02030 -0.46 0.6462 karno -0.12466 0.88279 0.02879 -4.33 1.5e-05 tt(karno) 0.02131 1.02154 0.00661 3.23 0.0013 Likelihood ratio test=53.8 on 4 df, p=5.7e-11 n= 137, number of events= 128
survfit though doesn't work when you have tt term
> survfit(vfit3, veteran[1, ]) Error in survfit.coxph(vfit3, veteran[1, ]) : The survfit function can not yet process coxph models with a tt term
However, you can easily get terms , a linear predictor, or average response with predict . Alternatively, you can create a term over time for the term tt using the answer here .
source share