plot - 如何在 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)
解决方案
您没有提供示例数据,因此我为此使用了生存::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)
推荐阅读
- spring-boot - RequestHandlerRetryAdvice 无法在 Spring Integration 中与 Ftp.outboundGateway 一起使用
- ios - 在 Mapbox iOS SDK 的标记下移动地图
- spring - 当我使用 ng build 时,proxy.conf.json 在 Angular 6 中不起作用
- android - 仅在某些活动中的操作栏?
- ruby-on-rails - 在 Rails 中添加复杂的查询
- python - 试图总结投资金额,但一直说不可迭代
- ansible - 确定演出主持人
- spring - 如何为 Spring Boot 配置服务器设置超时值
- c# - 无法从传输连接读取数据:现有连接被远程主机强行关闭
- x509certificate - 如何获得测试 eIDAS 证书