# Hazard ratio for more than two groups

Consider the line of code below for implementing Cox model in R and finding the hazard ratio:

 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?

Further Information:

head(data)

Survival Death clusters

" 345"   "0"   "1"

"  85"   "0"   "1"

"1058"   "0"   "1"

" 964"   "1"   "1"

"1315"   "0"   "2"

" 669"   "0"   "2"

summary(fitcox) https://i.stack.imgur.com/96DMh.png

• Can you plot the raw output and a sample of the data? Something like the output of head(data) – Demetri Pananos Apr 5 '19 at 17:33
• Please consider it now. – Omar Rafique Apr 5 '19 at 18:54
• Yea. This is what I was looking for. Thanks with $as.factor$ it is giving me 3 hazard ratios for clusters1, cluster2, cluster3. Does it mean that cluster1 is the reference? – Omar Rafique Apr 5 '19 at 19:05
• Since this is what it was i post it as the answer.. – user213325 Apr 5 '19 at 19:08
• Yes, this is normal behavior. You can read about dummy coding, here for example statisticssolutions.com/dummy-coding-the-how-and-why – user213325 Apr 5 '19 at 19:21

data$$clusters <- as.factor(data$$clusters)

data$$clusters <- relevel(data$$clusters, "name_of_group")