[R] Plotting survival curves from a Cox model with time dependent covariates

Terry Therneau therneau at mayo.edu
Fri Jul 15 15:19:18 CEST 2011


 The time-transform (tt() arguments) feature is the most recent addition
to coxph.  Most of the follow-up functions, in particular survfit(fit)
have not yet been updated to deal with such models.  Your message points
out that I need to at least update them to add a "not yet available"
error message.  
  I'm still learning what can be done with the tt() option.  If I assume
that your trmt variable is 0/1, then the code below is a clever way to
look at time dependent treatment effects.  I had not thought of it.

 Terry Therneau

--- begin included message ---

Let's assume I have a clinical trial with two treatments and a time to 
event outcome. I am trying to fit a Cox model with a time dependent 
treatment effect and then plot the predicted survival curve for one 
treatment (or both).

library(survival)
test <- 
list(time=runif(100,0,10),event=sample(0:1,100,replace=T),trmt=sample(0:1,100,replace=T))
model1 <- coxph(Surv(time, event) ~ tt(trmt), data=test, tt=function(x, 
t, ...) pspline(x + t))



More information about the R-help mailing list