[R] Survival prediction
Terry Therneau
therneau at mayo.edu
Mon Oct 8 15:25:31 CEST 2012
> Dear All,
>
> I have built a survival cox-model, which includes a covariate * time interaction. (non-proportionality detected)
> I am now wondering how could I most easily get survival predictions from my model.
>
> My model was specified:
> 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 a prediction using survfit and providing new.data for the combination of variables
> I am doing the predictions:
> survfit(cox, new.data=new)
Some comments:
1. even though it is in the SAS manual and some literature, I have myself never used
"X * log(time)" as a fix for lack of proportionality. Is it really true that when you
use
fit <- coxph(Surv(event_time_mod, event_indicator_mod) ~ Sex +
ageC + HHcat_alt + Main_Branch + Acute_seizure + TreatmentType_binary +
ICH + IVH_dummy)
zfit <- cox.zph(fit, transform="log")
plot(zfit[8])
that the estimated function is linear? I have not yet seen such a simple time effect
and would find it interesting.
2. The code you wrote does not fit the time dependent model that you suppose; it
treats event_time_mod as a fixed covariate. To fit the model see the relevant vignette
for the survival package. Essentially the program has to build a large (start, stop) data
set behind the scenes. (SAS does the same thing). Defining proper residuals for said
data set is hard and the R code does not yet do this. (Last I checked, SAS did the same
thing.)
3. The "survival curve" for a time dependent covariate is something that is not
easily defined. Read chapter 10.2.4 of the Therneau and Grambch book for a discussion of
this (largely informed by the many mistakes I've myself made.)
Terry Therneau
More information about the R-help
mailing list