On Nov 25, 2012, at 5:17 PM, Brent Caldwell wrote:
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).
Only give it newdata values that have the desired levels. Failing that
advice being on point, then please provide str(survmat) and
str(simple.cox.ethnicity$terms) .
(Could it be the case that your use of factor() around the terms means
that getting hte names of your terms are not what you think they are?
If the newdata argument is malformed then it gets discarded and the
original values get used. Maybe you should do the "factorization"
before you do the fit.)
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")
--
David Winsemius, MD
Alameda, CA, USA
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.