如何从 R 的 coxph 中获得 95% CI?

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

我在 R 的 coxph() 中使用了以下函数来拟合 cox 风险模型。我想报告适当的统计数据;但是,输出中没有 95% CI。

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

我只得到以下列。

coef exp(coef) se(coef) z p

获取与预测变量相关的风险比的置信区间的一种简单方法是对模型拟合使用 "summary" 函数。如果您想要系数估计值本身的置信区间,您可以使用 "confint" 函数。 confint 结果的指数也可用于获得风险比置信区间。

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

如果您需要进一步处理,请考虑使用 broom:

tidy 解决方案
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

更多详情请见 this reference

您可以简单地在 R 中的 CoxPH 模型摘要中找到 CI conf.int(如果使用 survival 包。它在 lower .95upper .95

2019 年更新(但我假设该建议以前没有用):

test1 <- list(time=c(4,3,1,1,2,2,3), 
              status=c(1,1,1,0,1,1,0), 
              x=c(0,2,1,1,1,0,0), 
              sex=c(0,0,0,0,1,1,1)) 
# Fit a stratified model 
coxobj <- coxph(Surv(time, status) ~ x + strata(sex), test1) 
coxobj_summary <- summary(coxobj)
coxobj_summary$conf.int

输出:

   exp(coef)  exp(-coef) lower .95 upper .95
x   2.230706   0.4482887 0.4450758  11.18022