Search code examples
rconfidence-interval

How to get 95% CI from R's coxph?


I have used the following function in R's coxph() to fit a cox hazard model. I want to report the proper statistics; however, there is no 95% CI in the output.

Surv(days, censor) ~ gender + age + treatment, data_1)

I only get the following columns.

coef exp(coef) se(coef) z p


Solution

  • A simple way to get confidence intervals for the hazard ratios associated with your predictor variables would be to use the "summary" function on your model fit. If you want confidence intervals for the coefficient estimates themselves you could use the "confint" function. Exponentiation of the results from confint can also be used to get the hazard ratio confidence intervals.

    fit <- coxph(Surv(t,y) ~ x)
    summary(fit)  #output provides HR CIs
    confint(fit)  #coefficient CIs
    exp(confint(fit))  #Also HR CIs