Doc*_*Doc 4 r package survival-analysis
I\xc2\xb4m 尝试使用 R 包“JM”通过联合模型将纵向时间拟合到事件数据。这是我第一次尝试联合模型,并遵循教科书的方法:
\n\naids.id <- aids[!duplicated(aids$patient),]\nlmeFit.aids <- lme(CD4~obstime + obstime:drug, random=~obstime|patient, data=aids)\ncoxFit.aids <- coxph(Sdurv(Time,death)~drug,data=aids.id, x=TRUE)\njointFit.aids <- jointModel(lmeFit.aids, coxFit.aids, timeVar="obstime",method="piecewise-PH-aGH")\nsummary(jointFit.aids)\nRun Code Online (Sandbox Code Playgroud)\n\n该代码按预期工作。但是当我使用自己的数据时,它就不再起作用了。
\n\nstr(DATA)\n\'data.frame\':6436 个观测值。共 13 个变量:\n $ patnr :带 1669 个级别的因子 "0010000158","0010000278",..: 4 4 4 4 7 7 7 7 7 7 ...
\n\n$ 性别 : 2 个级别“1”、“2”的因子: 1 1 1 1 1 1 1 1 1 1 ...
\n\n$ 日期:POSIXct,格式:“2008-08-08”“2010-01-25”“2012-02-24”“2012-04-21”...
\n\n$时间:号码 1355 1355 1355 1355 834 ...
\n\n$ 克雷亚:数字 7.4 9.6 12.3 10.3 0.8 ...
\n\n$ 半胱氨酸:数字 6.2 5.84 6.17 5.32 0.9 0.94 0.92 0.91 0.91 0.91 ...
\n\n$死亡日期:POSIXct,格式:“2012-04-24”“2012-04-24”“2012-04-24”“2012-04-24”...
\n\n$开始日期:POSIXct,格式:“2008-08-08”“2008-08-08”“2008-08-08”“2008-08-08”...
\n\n$ stop_date :POSIXct,格式:“2010-01-25”“2012-02-24”“2012-04-21”“2012-04-24”...
\n\n$ 开始:数字 0 535 1295 1352 0 ...
\n\n$ 停止:编号 535 1295 1352 1355 3 ...
\n\n$ obstime : 数字 0 535 1295 1352 0 ...
\n\n$事件:数字 0 0 0 1 0 0 0 0 0 0 ...
\n\n这些是数据帧的前 20 行:
\n\n patnr sex date time Crea CysC deathdate start_date stop_date start stop obstime event\n637 0010000343 1 2008-08-08 1355.00000 7.40 6.20 2012-04-24 2008-08-08 2010-01-25 0.00000 535.04167 0.00000 0\n816 0010000343 1 2010-01-25 1355.00000 9.60 5.84 2012-04-24 2008-08-08 2012-02-24 535.04167 1295.04167 535.04167 0\n1171 0010000343 1 2012-02-24 1355.00000 12.31 6.17 2012-04-24 2008-08-08 2012-04-21 1295.04167 1352.00000 1295.04167 0\n1201 0010000343 1 2012-04-21 1355.00000 10.35 5.32 2012-04-24 2008-08-08 2012-04-24 1352.00000 1355.00000 1352.00000 1\n1363 0010000873 1 2011-12-05 834.00000 0.80 0.90 <NA> 2011-12-05 2011-12-08 0.00000 3.00000 0.00000 0\n1370 0010000873 1 2011-12-08 834.00000 0.52 0.94 <NA> 2011-12-05 2011-12-09 3.00000 4.00000 3.00000 0\n1372 0010000873 1 2011-12-09 834.00000 0.45 0.92 <NA> 2011-12-05 2011-12-18 4.00000 13.00000 4.00000 0\n1386 0010000873 1 2011-12-18 834.00000 0.34 0.91 <NA> 2011-12-05 2011-12-19 13.00000 14.00000 13.00000 0\n1387 0010000873 1 2011-12-19 834.00000 0.31 0.91 <NA> 2011-12-05 2011-12-20 14.00000 15.00000 14.00000 0\n1391 0010000873 1 2011-12-20 834.00000 0.62 0.91 <NA> 2011-12-05 2011-12-27 15.00000 22.00000 15.00000 0\n1411 0010000873 1 2011-12-27 834.00000 0.61 1.44 <NA> 2011-12-05 2011-12-31 22.00000 26.00000 22.00000 0\n1418 0010000873 1 2011-12-31 834.00000 0.43 1.18 <NA> 2011-12-05 2012-01-01 26.00000 27.00000 26.00000 0\n1419 0010000873 1 2012-01-01 834.00000 0.46 1.22 <NA> 2011-12-05 2013-07-09 27.00000 581.95833 27.00000 0\n1466 0010000873 1 2013-07-09 834.00000 0.85 0.91 <NA> 2011-12-05 2014-03-18 581.95833 834.00000 581.95833 0\n1478 0010000873 1 2014-03-18 834.00000 1.20 1.00 <NA> 2011-12-05 2015-09-18 834.00000 1382.95833 834.00000 0\n2020 0010002412 1 2015-03-26 23.95833 1.16 0.85 <NA> 2015-03-26 2015-04-10 0.00000 14.95833 0.00000 0\n2035 0010002412 1 2015-04-10 23.95833 0.67 0.74 <NA> 2015-03-26 2015-04-14 14.95833 18.95833 14.95833 0\n2043 0010002412 1 2015-04-14 23.95833 0.56 0.75 <NA> 2015-03-26 2015-04-16 18.95833 20.95833 18.95833 0\n2046 0010002412 1 2015-04-16 23.95833 0.45 0.75 <NA> 2015-03-26 2015-04-17 20.95833 21.95833 20.95833 0\n2049 0010002412 1 2015-04-17 23.95833 0.52 0.86 <NA> 2015-03-26 2015-04-18 21.95833 22.95833 21.95833 0\nRun Code Online (Sandbox Code Playgroud)\n\n这是我使用的代码:
\n\ncopd.id <- DATA[!duplicated(DATA$patnr),]\ncopd.id$event <- as.numeric(!is.na(copd.id$deathdate))\n\nlmeFit.copd <- lme(CysC~obstime+obstime:sex, random=~obstime|patnr, data=DATA)\ncoxFit.copd <- coxph(Surv(time,event)~sex, data=copd.id, x=TRUE)\njointFit.copd <- jointModel(lmeFit.copd, coxFit.copd, timeVar="obstime",method="piecewise-PH-aGH")\n\nsummary(jointFit.copd)\nRun Code Online (Sandbox Code Playgroud)\n\n我收到以下错误消息:
\n\n\n\n\n\n\njointFit.copd <- jointModel(lmeFit.copd, coxFit.copd, timeVar="obstime",method="piecewise-PH-aGH") Fehler in\n jointModel(lmeFit.copd, coxFit.copd, timeVar = "obstime" ,方法=\n“piecewise-PH-aGH”):似乎在某些受试者的事件时间之后进行了纵向\n测量(即\n检查受试者:0010000343、0010000695、0010000873、0010002412、 \n 0010002782、0010003305、0010003865、0010003975、0010004179、\n 0010004534、0010004943、0010005724、0010007075、0010007495、 \n 0010008083、0010008279、0010008488、0010008692、0010008751、\n 0010009439、0010010330、0010011663、0010012262、0010012543、\ n 0010012575、0010013477、0010014195、0010015876、0010016684、\n 0010017677、0010018443、0010019213、0010019403、0010019646、\n 0010020446, 0010020695, 0010021115, 0010021159, 0010021916,\n 0010022698, 0010024937, 0010026652, 0010030656, 0010031115,\n 0010031654, 0010031760, 0010033685, 0010034046, 0010034303,\n 0010035140, 0010037655, 0010038043, 0010038117, 0010038168,\n 0010038622, 0010039907, 0010042346, 0010044178, 0010046528,\n 0010046756, 0010048385, 0010049308, 0010049625, 0010049854,\n 0010050309, 0010051869, 0010052193, 0010052645, 0010052927,\n 0010053024, 0010054182, 0010055882, 001
\n\n摘要(jointFit.copd) Fehler 摘要(jointFit.copd) : Objekt \'jointFit.copd\' nicht gefunden
\n
问题是:我检查了数据,事件发生后没有任何测量结果。
\n\n我在这里缺少什么?
\n在运行模型之前尝试排序DATA。我可以通过创建一个未排序的来patnr诱导您DATA在示例中得到的错误。aidsnewid
library(JM)
is.unsorted(aids$patient)
length(unique(aids$patient))
## make newid that is unsorted
no.rows <- rle(c(aids$patient))
aids$newid <- paste0(rep( rep(LETTERS, length.out=467), no.rows$lengths), aids$patient)
is.unsorted(aids$newid)
length(unique(aids$newid))
## change `patient` to newid in the following lines to get
## error message for `jointFit.aids`
aids.id <- aids[!duplicated(aids$patient),]
lmeFit.aids <- lme(CD4~obstime + obstime:drug, random=~obstime|newid, data=aids)
coxFit.aids <- coxph(Surv(Time,death)~drug,data=aids.id, x=TRUE)
jointFit.aids <- jointModel(lmeFit.aids, coxFit.aids, timeVar="obstime",method="piecewise-PH-aGH")
summary(jointFit.aids)
Run Code Online (Sandbox Code Playgroud)
当我在 github 上查看 JM 的代码时,我想到了这一点。由于错误消息打印在 jointModel.R 的第 139 行,我查看了该行上方的内容是如何定义的,并得出结论,假设数据集在 id 变量上排序。因此,虽然确实没有主体DATA违反条件,但代码中的顺序会被打乱。在没有可重现的示例的情况下,我的第一个提示是问题中给出的数据集的前 20 行 ID 为 0010000343、0010000873、0010002412,但发布的错误消息按排序顺序列出了 id 为0010000343、0010000695、0010000873, 0010002412 -- 表示未根据模型中列出的DATAid 变量 ( ) 进行排序。原始示例按 id ( )排序。patnrlme()aidspatient
| 归档时间: |
|
| 查看次数: |
1280 次 |
| 最近记录: |