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

问题描述 投票:0回答:4

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

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

我只得到以下几列。

coef exp(coef)  se(coef)     z       p

r confidence-interval
4个回答
15
投票

获取与预测变量相关的风险比的置信区间的一个简单方法是在模型拟合中使用“摘要”函数。如果您想要系数估计值本身的置信区间,您可以使用“confit”函数。限制结果的幂也可用于获取风险比置信区间。

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

5
投票

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

tidy
解决方案:
broom

更多详细信息请参见
此参考资料


2
投票
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

中的CI

模型摘要中找到
conf.int
CoxPH
(如果使用
R
包)。它位于
survival
lower .95
2019 年更新(但我认为该建议以前不起作用):

upper .95

输出:

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



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

summary(coxobj)$coefficients
输出并进行一些适合出版的调整以进一步输出处理的人来说可能会派上用场。
summary(coxobj)$conf.int

© www.soinside.com 2019 - 2024. All rights reserved.