The survfit.object help page says:
"The print.survfit method does more computation than is typical for a
print method and is documented on a separate page."
It takes a bit of digging, but after first trying:
getAnywhere(print.survfit) # and then following code and trying
getAnywhere(survmean) # survmean is the function which does the work
using pfun
... I think I finally understand exactly what the print.survfit help
page means when it refers to a "side-effect".
So there is no durable element in the survfit object that is the
median. The automation you request would involve duplicating the code
of survmean but with assignment of the "out" matrix to something that
does not get discarded.
--
David Winsemius
On Sep 8, 2009, at 6:42 PM, Polwart Calum (County Durham and
Darlington NHS Foundation Trust) wrote:
Hi,
I'm sure this should be simple but I can't figure it out! I want to
get the median survival calculated by the survfit function and use
the value rather than just be able to print it. Something like this:
library(survival)
data(lung)
lung.byPS = survfit(Surv (time, status) ~ ph.ecog, data=lung)
# lung.byPS
Call: survfit(formula = Surv(time, status) ~ ph.ecog, data = lung)
1 observation deleted due to missingness
n events median 0.95LCL 0.95UCL
ph.ecog=0 63 37 394 348 574
ph.ecog=1 113 82 306 268 429
ph.ecog=2 50 44 199 156 288
ph.ecog=3 1 1 118 Inf Inf
What I want is to be able to call the median using something like:
lung.byPS$median[ph.ecog=0]
so that I can add it to a plot like this:
plot (lung.byPS,
conf.int=F,
lty=1:4,
)
abline(h=0.5, lty=5)
abline(v=lung.byPS$median[ph.ecog=1])
abline(v=lung.byPS$median[ph.ecog=2])
Anyone got any easy solutions? Its fairly normal to plot across and
down to show medians on survival curves... so I'm sure it must be
possible to automate.
David Winsemius, MD
Heritage Laboratories
West Hartford, CT
______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.