[R] Plotting coxph survival curves

elegant-sheep cmw7 at ualberta.ca
Tue Jan 24 21:28:06 CET 2012


Hi,

I am attempting to plot survival curves estimated by cox proportional
hazards regression model.  The formula for the model is this:

F.cox.weight <- coxph(Surv(Lifespan, Status) ~ MS + Weight + Laid + MS:Laid
+ Weight:Laid, data = LongF)

MS = Mating status (mated/virgin)
Weight = adult female weight, continuous covariate
Laid = number of eggs laid by each female, continuous covariate

I want to plot female survival, as estimated by my model, by mating status
and therefore two survival curves should be plotted.  My code results in one
survival curve bounded by, what I assume are confidence intervals.

My code for the plot is:

plot(survfit(F.cox.weight), lty=c(1,3), ylab = "Survivorship", xlab = "Day",
bty="L")
legend(35,0.9,c("Mated","Virgin"), lty=c(1,3), bty = "n")

The plot looks like this:
http://r.789695.n4.nabble.com/file/n4325120/Fig_survival_female.jpg 

Probably a simple bit of code I'm missing!

Cheers,


--
View this message in context: http://r.789695.n4.nabble.com/Plotting-coxph-survival-curves-tp4325120p4325120.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list