# Is doing Kaplan-Meier for 2 curves equivalent to ajdusting for a covarite or stratyfing in Cox? I want the HR for my KM curves

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)?

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.

library(survival)
ovarian=ovarian[order(ovarian$$rx,ovarian$$futime),]

cox1=coxph(Surv(futime,fustat) ~ rx, data = ovarian)
plot(survfit(Surv(futime,fustat) ~ rx, data = ovarian),col=c("red","blue"))
points(ovarian$futime,predict(cox1,type="survival"),col=c(rep("red",13),rep("blue",13))) cox2=coxph(Surv(futime,fustat) ~strata(rx), data = ovarian) plot(survfit(Surv(futime,fustat) ~ rx, data = ovarian),col=c("red","blue")) points(ovarian$futime,predict(cox2,type="survival"),col=c(rep("red",13),rep("blue",13)))


• 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/… Apr 8, 2021 at 13:51
• 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 Apr 8, 2021 at 15:07