[R] Predictions from "coxph" or "cph" objects

David Winsemius dwinsemius at comcast.net
Sat Jul 5 19:54:14 CEST 2014

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`.

?quantile.survfit   # to get the median


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

More information about the R-help mailing list