[R] Fitting and plotting a coxph with survfit, package(surv)

Terry Therneau therneau at mayo.edu
Wed Nov 28 16:12:29 CET 2012


I answered a similar question yesterday:
"The survfit routine will produce predicted survival curves for any requested combination 
of the covariates in the original model.  This is not the same thing as an "adjusted" 
survival curve.  Confusion on this is prevalent, however.  True adjustment requires a 
population average over the confounding factors and is closely related to the standardized 
incidence ratio concept found in epidemiology."

To do this you need to define a poplation of ages.  See chapter 10 of the book by Therneau 
and Grambsch for an explantion of the issues and examples of how to get the population 
value.  It's hard to distill 20 pages down into an email message.

Terry Therneau

---------- begin included message ---------

I have a database with 18000 observations and 20 variables. I am running
cox regression on five variables and trying to use survfit to plot the
survival based on a specific variable without success.

Lets say I have the following coxph:
 >library(survival)
 >fit <- coxph(Surv(futime, fustat) ~ age + rx, data = ovarian)
 >fit
what I am trying to do is plot a survival comparing objects based on rx.
Using this
 >plot(survfit(fit, newdata=data.frame(rx =c(1:2), age=c(60)),
              xscale=365.25, xlab = "Years", ylab="Survival"))
I get the survival for patients at 60, but is there an option to get a
survfit for the patients regardless of the value in variable "age"?




More information about the R-help mailing list