# How to calculate Hazard ratio if there are more than two Kaplan-Meier curves

A population was sub-typed into 4 groups and Kaplan-Meier curves were plotted. If there were only two survival curves then the hazard ratio would be the hazard of one group divided by the hazard of the other. How do we find the hazard ratio when there are more than two groups? Does it even make sense to do so?

This depends on what the multiple groups are.

For example, they might be a placebo group and 3 different drugs. Then one might compare each drug with the placebo, and perhaps also each drug versus the other ones.

Alternatively, the groups could be for drug A with history of some disease, without history, placebo with history and without history. In that case, you might be interested in the hazard ratio of drug versus placebo within subgroup, or an overall drug versus placebo one adjusted or stratified for disease history.

• my confusion arises from the following implementation in R: Suppose, I have the following line of code: fitcox <- coxph(Surv(Survival,Death) ~ clusters, data = data).... Here "clusters" is a vector with 30 values as 1, 30 values as 2 ,30 values a 3 and 30 values as 4. The Kaplan-Meier graph consists of 4 plots ; one for each cluster. When I run the above command, the hazard ratio comes out to be 1.3154 (i.e. exp(coef) in R).What does that mean?I mean I have 4 groups but hazard ratio is supposed to be between 2 groups only. What does R mean by 1.3154.. Apr 5, 2019 at 9:56
• I suspect the coxph function thinks you are giving a continuous variable ranging from 1 to 4 and is estimating the hazard ratio for the increase by 1 unit in the clusters variable. This really only makes sense if this is a continous variable, where a difference of 1 from 1 to 2 means the same thing as the difference from 3 to 4 and son on, and you think that the effect on the log hazard ratio should reasonably be twice that when going from 1 to 3 or 2 to 4. From how you describe this, I assume that is not waht is going on and you may want coxph(Surv(Survival,Death) ~ as.factor(clusters)). Apr 5, 2019 at 12:58
• To clarify it further, 1,2,3 and 4 are names of clusters.....I could have used A,B,C, and D... So, you are right in using as.factor. ...Thanks for pointing that out. I used as.factor(clusters) and it is now giving 3 hazard ratios as : as.factor(cluster2) = 3.4772 , as.factor(cluster3) = 0.7027, as.factor(cluster4) = 1.5584. Am I correct in assuming that all these hazard ratios have been calculated w.r.t. hazard of cluster 1.. Apr 5, 2019 at 14:16
• It sounds like this might be helpful Apr 5, 2019 at 17:45
• They are indeed all with reference to a reference category, I would confirm in the documentation how this is chosen by default (alphabetical? Data order?). Apr 5, 2019 at 18:03

It does not make sense to do so. A hazard ratio is, by definition, a measure that compares exactly two groups. If you have K-M survivor curves four groups, say, A, B, C, and D, then you have exactly six possible comparisons which you could make:

• A vs B
• A vs C
• A vs D
• B vs C
• B vs D
• C vs D

For example, you could calculate six different hazard ratios, one for each of these comparisons.

• Thanks for the answer. I agree with you, but my confusion arises from the following implementation in R: Apr 5, 2019 at 9:46