小编Cha*_*e B的帖子

当因子分层时,在 RStudio 中使用 ggforest 绘制 Cox PH 模型?

当需要对模型变量之一进行分层时,我试图找到一种方法来从 Cox-PH 模型制作风险比的森林图。对于非分层模型,该ggforest()功能非常出色。运行一些示例代码

library(survival)
library(survminer)

model <- coxph(Surv(time, status) ~ sex + rx + adhere,
               data = colon )
ggforest(model)

colon <- within(colon, {
  sex <- factor(sex, labels = c("female", "male"))
  differ <- factor(differ, labels = c("well", "moderate", "poor"))
  extent <- factor(extent, labels = c("submuc.", "muscle", "serosa", "contig."))
})
bigmodel <-
  coxph(Surv(time, status) ~ sex + rx + adhere + differ + extent + node4,
        data = colon )
ggforest(bigmodel)
Run Code Online (Sandbox Code Playgroud)

产生这个图

非分层图

但是,如果我必须纠正分层的非比例性

stratamodel <- coxph(Surv(time, status) ~ sex …
Run Code Online (Sandbox Code Playgroud)

r ggplot2 survminer

4
推荐指数
1
解决办法
1051
查看次数

标签 统计

ggplot2 ×1

r ×1

survminer ×1