Thank you David. It is my understanding that using survit below I get the median predicted survival. I actually was looking for the mean. I can't seem to find in the documentation how to get that.
options(na.action=na.exclude) # retain NA in predictions fit <- coxph(Surv(time, status) ~ age + ph.ecog, lung) pred <- survfit(fit, newdata=lung) head(pred) Thanks again, Axel. On Sat, Jul 5, 2014 at 1:54 PM, David Winsemius <dwinsem...@comcast.net> wrote: > > On Jul 5, 2014, at 5:28 AM, Axel Urbiz wrote: > > Dear R users, >> >> My apologies for the simple question, as I'm starting to learn the >> concepts >> behind the Cox PH model. I was just experimenting with the survival and >> rms >> packages for this. >> >> I'm simply trying to obtain the expected survival time (as opposed to the >> probability of survival at a given time t). >> > > What does "expected survival time" actually mean? Do you want the median > survival time? > > > I can't seem to find an option >> from the "type" argument in the predict methods from coxph{survival} or >> cph{rms} that will give me expected survival times. >> >> library(rms) >> options(na.action=na.exclude) # retain NA in predictions >> fit <- coxph(Surv(time, status) ~ age + ph.ecog, lung) >> fit2 <- cph(Surv(time, status) ~ age + ph.ecog, lung) >> head(predict(fit,type="lp")) >> head(predict(fit2,type="lp")) >> > > `predict` will return the results of the regression, i.e. the log-hazard > ratios for each term in the RHS of the formula. What you want (as described > in the Index for the survival package) is either `survfit` or `survexp`. > > require(survival) > help(pack=survival) > ?survfit > ?survexp > ?summary.survfit > ?quantile.survfit # to get the median > ?print.summary.survfit > > require(rms) > help(pack=rms) > > The rms-package also adds a `survfit.cph` function but I have found the > `survest` function also provides useful added features, beyond those > offered by survfit > > >> >> Thank you. >> >> Regards, >> Axel. >> >> [[alternative HTML version deleted]] >> > > This is a plain text mailing list. > > -- > > David Winsemius, MD > Alameda, CA, USA > > [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org 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.