0
$\begingroup$

My population is divided into 10 groups. I want to run the cox-proportional hazard model separately for each of these 10 groups so that in the end i can compare which groups has highest hazard ratio depending uopn the covariates. How can i do this in R? Earlier i was using this formula.

Model_1 <- coxph(serve_object ~ GROUP + age+ Smoking+ Diabetes, data = DF
summary(Model_1)

But the output is very confusing. it gives hazard ratio of 9 out of 10 groups. I think it dealt group as covariate.

$\endgroup$
2
$\begingroup$

The fact that you supplied GROUP as a covariate, you are getting 9 coefficients as one of the ten levels is used as the reference level.

If you would like to fit one model per group (and in this scenario you would not be correcting for GROUP), you should first split your data frame and fit your models on the resulting list's elements:

lapply(split(DF, DF$GROUP),
       function(x) coxph(serve_object ~ age + Smoking + Diabetes, data = DF))

Example with the mtcars data set when grouped by number of cylinders, cyl having values of 4, 6 or 8:

> lapply(split(mtcars, mtcars$cyl),
+        function(x) lm(disp ~ hp, data = x))
$`4`

Call:
lm(formula = disp ~ hp, data = x)

Coefficients:
(Intercept)           hp  
    59.0369       0.5579  


$`6`

Call:
lm(formula = disp ~ hp, data = x)

Coefficients:
(Intercept)           hp  
   290.9178      -0.8799  


$`8`

Call:
lm(formula = disp ~ hp, data = x)

Coefficients:
(Intercept)           hp  
   320.2083       0.1572  
$\endgroup$
7
  • $\begingroup$ Can you help me in interpreting result. .$Group3 Call: coxph(formula = so_ukb ~ age_at_recruitment.210220.0 + Smoking + Hypertention, data = UKB_FILTRD) coef exp(coef) se(coef) z p age_at_recruitment.210220.0 0.06961 1.07208 0.00141 49.35 <2e-16 Smoking.L -0.21220 0.80880 0.01335 -15.90 <2e-16 Hypertention.L -0.44221 0.64262 0.01361 -32.49 <2e-16 Likelihood ratio test=5142 on 3 df, p=< 2.2e-16 n= 448287, number of events= 11377 (3270 observations deleted due to missingness) $\endgroup$
    – Aryh
    Apr 28 '20 at 12:29
  • $\begingroup$ I am just confused that how to get one cumulative hazard ratio by adjusting model for these covariates. It is giving HR for age, smoking, hypertention separatively.. I want to see just cumulative. $\endgroup$
    – Aryh
    Apr 28 '20 at 12:31
  • $\begingroup$ Thank you for above lapply code, it worked so well. $\endgroup$
    – Aryh
    Apr 28 '20 at 12:31
  • $\begingroup$ Let's take the coefficient you get for age: The exp() of this coefficient is the change in in HR when age changes by one unit and while all the other variables are accounted for. In that sense, it takes all the variables into account so can be said to be "cumulative", although I am not sure such terminology exists for linear models. You might want to use interaction terms if your covariates depend on each other. $\endgroup$
    – haci
    Apr 28 '20 at 12:44
  • $\begingroup$ Can you give an idea of how we can export the summary(coxph) into csv? $\endgroup$
    – Aryh
    Apr 28 '20 at 14:36

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.