如何用两组绘制 CoxPH 模型?

问题描述

我正在尝试绘制一个 cox 模型,并让它根据因子变量 (shunttyp) 显示 2 个组。我尝试了以下代码

coxph.model <- coxph(Surv(days,sens)~male+ coceva + ptatot + diatot + compldich + duplflow1 + shunttyp,data=cox1df)

ggsurvplot(survfit(coxph.model),palette= "#2E9FDF",ggtheme = theme_minimal(),cox1df)

这成功地绘制了完整模型。我对基于变量“shunttyp”的曲线感兴趣,该变量是一个因子变量。

但是下面的代码不起作用。

ggsurvplot(survfit(coxph.model),group.by = "shunttyp",data= cox1df)

ggsurvplot(survfit(coxph.model),strata = c("shunttyp"),data = cox1df)

我曾尝试在网上 (sthda.com) 上举一个例子,结果导致我:

new_df <- with(cox1df,data.frame(male = c(1,2),coceva = c(1,1),compldich = c(1,shunttyp = c(1,ptatot = rep(mean(ptatot,na.rm = TRUE),diatot = rep(mean(diatot,duplflow1 = rep(mean(duplflow1,2) ))

但老实说,我不知道这是否正确或我在这里做什么。

我的目标是得到一个看起来像这样的地块,但地层是 shunttyp=0 和 shunttyp=1。

enter image description here

我不知道如何到达那里,并且花了几天时间试图在网上找到答案。非常感谢任何帮助。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)