作为一个例子,我正在运行几个生存模型,每个模型都有一组不同的协变量。
> coxph = coxph(Surv(time, event) ~ tr.ma, data = first.data, method = "breslow")
> summary(coxph)
Call:
coxph(formula = Surv(time, event) ~ tr.ma, data = first.data,
method = "breslow")
n= 49, number of events= 46
(1 observation deleted due to missingness)
coef exp(coef) se(coef) z Pr(>|z|)
tr.ma 0.09520 1.09988 0.03906 2.437 0.0148 *
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
exp(coef) exp(-coef) lower .95 upper .95
tr.ma 1.1 0.9092 1.019 1.187
Concordance= 0.694 (se = 0.058 )
Rsquare= 0.109 (max possible= 0.997 )
Likelihood ratio test= 5.68 on 1 df, p=0.01718
Wald test = 5.94 on 1 df, p=0.0148
Score (logrank) test = 5.93 on 1 df, p=0.01485
> coxph = coxph(Surv(time, event) ~ tr.ma + contag_per, data = first.data, method = "breslow")
> summary(coxph)
Call:
coxph(formula = Surv(time, event) ~ tr.ma + contag_per, data = first.data,
method = "breslow")
n= 49, number of events= 46
(1 observation deleted due to missingness)
coef exp(coef) se(coef) z Pr(>|z|)
tr.ma 0.09801 1.10297 0.04231 2.317 0.020518 *
contag_per -1.97309 0.13903 0.51683 -3.818 0.000135 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
exp(coef) exp(-coef) lower .95 upper .95
tr.ma 1.103 0.9066 1.01521 1.1983
contag_per 0.139 7.1929 0.05049 0.3828
Concordance= 0.752 (se = 0.058 )
Rsquare= 0.348 (max possible= 0.997 )
Likelihood ratio test= 20.98 on 2 df, p=2.78e-05
Wald test = 19.33 on 2 df, p=6.357e-05
Score (logrank) test = 20.73 on 2 df, p=3.147e-05
我希望从每个模型的输出中获取exp(coef), Pr(>|z|)
并将它们收集到以LaTex格式化的表格中,以生成简明的报告。类似的东西:
Model covariates exp(coef) p-value
----------------------------------------
1 tr.ma 1.099 0.0148
2 tr.ma 1.103 0.0205
contag_per 0.139 0.00013
...
如果我可以实现自动化,那将是非常棒的,因为我有大约25个模型,并且必须手动检索并输入表中的数字将非常不方便且容易出错。感谢。