[R] Extended Survival Plot Lines

Terry Therneau therneau at mayo.edu
Fri Mar 9 14:29:14 CET 2012


> ...  Is there a way to extend all the lines to make them end at a
>  certain time point? (i.e outcome.[,1] is a time to event variable and
>  I would like thesurvival lines on the plot to extend out to say
>  5(years) )

No, there is no option in the plot.survival function to do this.  No one
has ever asked for this feature before (the function was written in
about 1988), so you are breaking new ground.  It is standard practice to
end a survival curve at the last observed time point; you are not likely
to convince me to add this as an option.

You can always plot the curves yourself:
   fit <- survfit(Surv(1:5, c(1,0,1,0,0)) ~1)
   plot(fit$time, fit$surv, type='s')  
   plot(c(0, fit$time), c(1, fit$surv), type='s') #Oops, add time 0 on

The key is using type='s' for a step function.  You can now tack on an
extra time point of your choice, 6 say, with c(0, fit$time, 6) for x and
c(1, fit$surv, min(fit$surv)) for y.  For multiple curves look more
closely at help("survfit.object")

Terry Therneau



More information about the R-help mailing list