[R] How does one plot the -log(log(survival))
Thomas Lumley
tlumley at u.washington.edu
Mon May 11 01:23:48 CEST 2009
On Sun, 10 May 2009, John Sorkin wrote:
> R 2.8.1
> Windows XP
>
> How does one plot the -log(log(survival)) from a coxph? Survfit does not seem
> to be up to the task.
It depends on what you mean.
You can convert the plots to a -log(log(survival)) scale with the option fun="cloglog". In the example from my previous reply
plot(survfit(fit, newdata=data.frame(age=c(40,50,60))),
xscale=365.25, xlab = "Years", ylab="Survival",fun="cloglog")
This is a bit pointless: since these curves are from a Cox model, they are exactly parallel on a -log(log(survival)) scale.
People sometimes want to fit a model where they stratify on one covariate and plot the two baseline hazards. You can do this like:
sfit<-coxph(Surv(futime, fustat) ~ age+strata(rx), data = ovarian)
plot(survfit(sfit),fun="cloglog")
One motivation given for doing this is examining the proportional hazards assumption, but this is not a very good way of doing it. The eye is not very good at judging whether there is a constant vertical separation between curves, even before you take into account that the uncertainty varies dramatically along the curve. I would use cox.zph() and plot.cox.zph(), which give valid formal tests and reasonable estimates of how the log hazard ratio varies with time. Still, if you want to do log-log plots, the survival package is up to the task.
-thomas
Thomas Lumley Assoc. Professor, Biostatistics
tlumley at u.washington.edu University of Washington, Seattle
More information about the R-help
mailing list