log-minus-log plot
on 02/20/2009 07:23 AM Frank E Harrell Jr wrote:
C.H. wrote:
Dear experts, I would like to know how to plot the log-minus-log plot for survival analysis (to check the proportional assumption) in R. Using the AML example. fit <- survfit(Surv(time, status) ~ x, data=aml) length(fit$surv) #20 as the length of fit$surv is shorter than aml$x and aml$time. I don't know how to plot. Thank you. Regards, CH
library(Design) # uses library(survival) fit <- survfit(. . .) survplot(fit, loglog=TRUE) ?survplot for details
Just to throw out another possibility, using a Cox model on the data:
library(survival)
fit <- coxph(Surv(time, status) ~ x, data = aml)
> cox.zph(fit)
rho chisq p
xNonmaintained 0.0198 0.00691 0.934
# create plot. default transform = "km"
plot(cox.zph(fit, transform = "log"))
See ?coxph, ?cox.zph and ?plot.cox.zph in 'survival'.
HTH,
Marc Schwartz