How to get 95% CI from R's coxph?
13,365
If you need this for further processing, consider a tidy
solution with broom
:
library(broom)
library(dplyr)
library(survival)
mod <- coxph(Surv(time, status) ~ sex + age, data = lung)
mod |>
tidy(conf.int = TRUE, exponentiate = TRUE) |>
select(term, estimate, starts_with("conf"))
#> # A tibble: 2 x 4
#> term estimate conf.low conf.high
#> <chr> <dbl> <dbl> <dbl>
#> 1 sex 0.599 0.431 0.831
#> 2 age 1.02 0.999 1.04
More details at this reference
Comments
-
ejg over 1 year
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