1
$\begingroup$

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) 

enter image description here

https://i.sstatic.net/96DMh.png

$\endgroup$
8
  • 2
    $\begingroup$ Can you plot the raw output and a sample of the data? Something like the output of head(data) $\endgroup$ Commented Apr 5, 2019 at 17:33
  • $\begingroup$ Please consider it now. $\endgroup$ Commented Apr 5, 2019 at 18:54
  • $\begingroup$ 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? $\endgroup$ Commented Apr 5, 2019 at 19:05
  • 1
    $\begingroup$ Since this is what it was i post it as the answer.. $\endgroup$
    – user213325
    Commented Apr 5, 2019 at 19:08
  • 2
    $\begingroup$ Yes, this is normal behavior. You can read about dummy coding, here for example statisticssolutions.com/dummy-coding-the-how-and-why $\endgroup$
    – user213325
    Commented Apr 5, 2019 at 19:21

1 Answer 1

2
$\begingroup$

I guess your predictor has the class "numeric" and thus R thinks it is one continuous variable and determines the hazard ratio for this one variable. If this is the case all you need to do is

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

After that R will provide three hazard ratios, each showing the hazard ratio of a given group versus the reference. You can change the refernce group with.

data$clusters <- relevel(data$clusters, "name_of_group")
$\endgroup$
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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