[R] extending survival curves past the last event using plot.survfit

David Winsemius dwinsemius at comcast.net
Thu Sep 23 05:53:26 CEST 2010


On Sep 22, 2010, at 8:15 PM, Krambrink, Amy M wrote:

> Hello,
>
>
>
> I'm using plot.survfit to plot cumulative incidence of an event.
> Essentially, my code boils down to:
>
> cox <-coxph(Surv(EVINF,STATUS) ~ strata(TREAT) + covariates, data=dat)
>
> surv <- survfit(cox)
>
> plot(surv,mark.time=F,fun="event")
>
> Follow-up time extends to 54 weeks, but the last event occurs at week
> 30, and no more people are censored in between.  Is there a direct way
> to extend the curves with a horizontal line to the end of follow-up  
> (54
> weeks), rather than stopping at the time of the last event (30 weeks)?

Not sure if it's the approved method, but this works:
 > ?survfit.object
 > ?survfit   # to get a working example since you did not provide one
 > lsurv2 <- survfit(Surv(time, status) ~ x, aml, type='fleming')
 > plot(lsurv2, lty=2:3, xmax=300)  # drats, no effect of xmax
 > str(lsurv2)      # so see the structure of the survfit object
 > lsurv2$time[21] <- 300         #add a time value
 > lsurv2$n.censor[21] <- 1       # mark as censoring time
 > lsurv2$strata[2] <- 11         # add to count of group 2
 >
 > plot(lsurv2, lty=2:3, xmax=300)  # horizontal line to 300 for group 2
>
>
>
> I've pretty much exhausted my search options and didn't see this in a
> previous thread, so would really appreciate any help or thoughts!
>
>
>
> Thanks in advance!
>
> Amy

PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
-- 
David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list