How to make predictions from a coke survival model with time-varying coefficients

I built a surviving coke model that includes covariate * time interaction (inconsistency detected). Now I wonder how I can easily get survival predictions from my model.

My model was indicated:

 coxph(formula = Surv(event_time_mod, event_indicator_mod) ~ Sex + ageC + HHcat_alt + Main_Branch + Acute_seizure + TreatmentType_binary + ICH + IVH_dummy + IVH_dummy:log(event_time_mod) 

And now I was hoping to get the prediction using survfit and providing new.data for the combination of variables that I do for predictions:

 survfit(cox, new.data=new) 

Now that I have event_time_mod on the right side of my model, I need to specify it in a new data frame passed to survfit . This event_time must be set at individual points in the predictions. Is there an easy way to specify event_time_mod as the correct time for survfit ? Or are there other options to achieve my model predictions?

Of course, I could create as many rows in the new data frame as many times in the predictions and settings of event_time_mod to correct the values, but they seem very cumbersome, and I thought that there should be a better way.

+4
source share
1 answer

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 .

+1
source

Source: https://habr.com/ru/post/1438152/


All Articles