[R] Plotting an adjusted kaplan-meier curve

Brent Caldwell brent.caldwell at otago.ac.nz
Mon Nov 26 02:17:11 CET 2012


Dear R-users
I am trying to make an adjusted Kaplan-Meier curve (using the Survival package) but I am having difficulty with 
plotting it so that the plot only shows the curves for the adjusted results.  
My data come from a randomised controlled trial, and I would like the adjusted Kaplan-Meier 
curve to only show two curves for the adjusted survival: one for those on treatment (Treatment==1) 
and another curve for those on placebo (Treatment==0).

My problem is that when I plot the survfit of my coxph, I think it displays a curve for 
every single individual factor in my coxph, whereas I would like it to only display the 
adjusted curves for when Treatment==1 and Treatment==0.  How can I do this?

A simplified example of my code with only one effect-modifier is:

simple.cox.ethnicity <- coxph(Surv(whenfailed,failed) ~ factor(Treatment) + factor(ethnicity)) #I've my data are attached already
survfit.simple.cox.ethnicity <- survfit(simple.cox.ethnicity,survmat) #survmat is a data.frame that contains Treatment and ethnicity
plot(survfit.simple.cox.ethnicity, col=c("red","black"), main="survfit.simple.cox", xlab="survival time", ylab="propotion surviving")

Thank you so much for your help.
Yours gratefully,
Brent Caldwell



More information about the R-help mailing list