首页 > 解决方案 > 如何在 X 轴(左截断数据)上绘制相对于一般人群的生存率?

问题描述

我试图将我的研究队列中的存活率与荷兰普通人群的存活率(年龄和性别匹配)进行比较。我创建了一个荷兰人口比率表。

library(relsurv)
setwd("")
nldpop <- transrate.hmd("mltper_1x1.txt","fltper_1x1.txt")

然后,我想在 X 轴上绘制我的队列(观察到的)的生存率和人口的生存率(预期)与年龄的关系图。但是,“survexp”函数似乎不支持(开始、停止、事件)格式。只有在正常的(futime,event)格式下它才能工作,见下文,但是我在 X 轴上有后续时间。有谁知道如何在 X 轴上获取年龄而不是后续时间?

# Observed and expected survival with time on X-axis
fit <- survfit(Surv(futime, event)~1)
efit <- survexp(futime ~ 1, rmap = list(year=(date_entry), age=(age_entry), sex=(sex)),
          ratetable=nldpop)
plot(fit)
lines(efit)

标签: plotsurvival-analysis

解决方案


您没有提供示例数据,因此我为此使用了生存::mgus 数据。您的问题可能是由于在 rmap 选项中错误地指定了变量名。看这里的情节

library(relsurv)
nldpop <- transrate.hmd("mltper_1x1.txt", "fltper_1x1.txt")

mgus2 <- mgus %>% mutate(date_year = dxyr + 1900)

fit <- survfit(Surv(futime, death) ~ 1, data = mgus2)
efit <- survexp(Surv(futime, death) ~ 1, data = mgus2, 
                ratetable = nldpop, rmap = list(age = age*365.25, year = date_year, sex = sex))
plot(fit)
lines(efit)


推荐阅读