Re: [R] What is median in survfit

From: Thomas Lumley <tlumley_at_u.washington.edu>
Date: Sat 11 Jun 2005 - 01:04:17 EST

On Fri, 10 Jun 2005, Remigijus Lapinskas wrote:

> Dear All,
>
> A very simple question:
>
> > library(survival)
> > fit <- coxph(Surv(time, status) ~ x, data=aml)
> > survfit(fit)
> Call: survfit.coxph(object = fit)
>
> n events median 0.95LCL 0.95UCL
> 23 18 30 18 45
>
> I believe I know what is median here, but how to extract it?
>

This turns out to be trickier than one would ideally like

   fit$time[min(which(fit$surv<=0.5))]
works if there is a single stratum, as in your example.

Or, even uglier, you can capture then entire table with
> read.table(textConnection(capture.output(survfit(fit))),skip=2,header=TRUE)

    n events median X0.95LCL X0.95UCL
1 23 18 30 18 45

which does work for stratified survfits.

         -thomas



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Sat Jun 11 01:11:29 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:32:30 EST