微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何用两组绘制 CoxPH 模型?

如何解决如何用两组绘制 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 举报,一经查实,本站将立刻删除。