Using the R terminology (but this is software independent statistical problem), is survfit(surv_object ~ rx, data = ovarian) returning 2 Kaplan-Meier curves the same as doing Cox with the same formula or is this more doing the Cox with using rx for stratification?

In other words, does the Kaplan-Meier assume same baseline risk in both groups (thus it's not stratification)?

My goal:

I have two categorical variables. A = {a1, b1}, B = {b1, b2}

I have two KM plots for the A (giving me 2 coloured curves {a1 and a2}) each per level of the B. I use the ggplot2, so the A is used for colours (... col =A) and B is used in facet_wrap(~B).

And now I want to calculate HR between the a1 and a2 per each level of B, I mean: HR_b1, HR_b2

I can do this using Cox. Should I type something: surv_object ~ A + B, surv_object ~ A * B or surv_object ~ A + strata(B)?


1 Answer 1


The Kaplan-Meier curves estimate the survival function in both groups separately without making any assumptions about any relationship between the two survival curves.

Try drawing the Kaplan-Meier curves, then adding the estimated survival using Cox regression models including treatment as a covariate and including treatment as a stratification factor.

The first one (treatment as a covariate assuming proportional hazards model) produces estimated survival proabbilities very different from Kaplan-Meier estimates. The second produces nearly identical estimates.


cox1=coxph(Surv(futime,fustat) ~ rx, data = ovarian)
plot(survfit(Surv(futime,fustat) ~ rx, data = ovarian),col=c("red","blue"))

cox2=coxph(Surv(futime,fustat) ~strata(rx), data = ovarian)
plot(survfit(Surv(futime,fustat) ~ rx, data = ovarian),col=c("red","blue"))

enter image description here

enter image description here

  • $\begingroup$ Thank you. This is exactly my concern I expressed in this thread - there is a big difference between the typical KM stratified and Cox with strata or covariate. So how to get the HR now? stats.stackexchange.com/questions/518732/… $\endgroup$
    – FordTaurus
    Apr 8, 2021 at 13:51
  • $\begingroup$ the hazard ratio is based on the proportional hazard assumption. otherwise, what does the hazard ratio mean without the proportional hazards assumption? there are some other interpretations such as an average over hazard ratios at different times- see here $\endgroup$
    – John L
    Apr 8, 2021 at 15:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.