我正在尝试使用R-package“JM”使用联合模型将事件数据的纵向时间拟合。这是我对联合模型的第一次尝试,并遵循教科书方法:
aids.id <- aids[!duplicated(aids$patient),]
lmeFit.aids <- lme(CD4~obstime + obstime:drug, random=~obstime|patient, data=aids)
coxFit.aids <- coxph(Sdurv(Time,death)~drug,data=aids.id, x=TRUE)
jointFit.aids <- jointModel(lmeFit.aids, coxFit.aids, timeVar="obstime",method="piecewise-PH-aGH")
summary(jointFit.aids)
代码按预期工作。但是当我使用自己的数据时,它就不再起作用了。
STR(DATA) 'data.frame':6436 obs。 13个变量: $ patnr:因子w / 1669水平“0010000158”,“0010000278”,..:4 4 4 4 7 7 7 7 7 7 ...
$ sex:因子w / 2级别“1”,“2”:1 1 1 1 1 1 1 1 1 1 ...
$ date:POSIXct,格式:“2008-08-08”“2010-01-25”“2012-02-24”“2012-04-21”......
$ time:num 1355 1355 1355 1355 834 ...
$ Crea:num 7.4 9.6 12.3 10.3 0.8 ...
$ CysC:num 6.2 5.84 6.17 5.32 0.9 0.94 0.92 0.91 0.91 0.91 ...
$ deathdate:POSIXct,格式:“2012-04-24”“2012-04-24”“2012-04-24”“2012-04-24”......
$ start_date:POSIXct,格式:“2008-08-08”“2008-08-08”“2008-08-08”“2008-08-08”......
$ stop_date:POSIXct,格式:“2010-01-25”“2012-02-24”“2012-04-21”“2012-04-24”......
$ start:num 0 535 1295 1352 0 ...
$ stop:num 535 1295 1352 1355 3 ...
$ obstime:num 0 535 1295 1352 0 ...
$ event:num 0 0 0 1 0 0 0 0 0 0 ...
这些是数据框的前20行:
patnr sex date time Crea CysC deathdate start_date stop_date start stop obstime event
637 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
816 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
1171 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
1201 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
1363 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
1370 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
1372 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
1386 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
1387 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
1391 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
1411 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
1418 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
1419 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
1466 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
1478 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
2020 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
2035 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
2043 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
2046 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
2049 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
这是我使用的代码:
copd.id <- DATA[!duplicated(DATA$patnr),]
copd.id$event <- as.numeric(!is.na(copd.id$deathdate))
lmeFit.copd <- lme(CysC~obstime+obstime:sex, random=~obstime|patnr, data=DATA)
coxFit.copd <- coxph(Surv(time,event)~sex, data=copd.id, x=TRUE)
jointFit.copd <- jointModel(lmeFit.copd, coxFit.copd, timeVar="obstime",method="piecewise-PH-aGH")
summary(jointFit.copd)
我收到以下错误消息:
jointFit.copd&lt; - jointModel(lmeFit.copd,coxFit.copd,timeVar =“obstime”,method =“piecewise-PH-aGH”)Fehler in jointModel(lmeFit.copd,coxFit.copd,timeVar =“obstime”,method = “分段-PH-aGH”):似乎有纵向 在某些科目的事件发生时间之后进行的测量(即 检查主题:0010000343,0010000695,0010000873,0010002412, 0010002782,0010003305,0010003865,0010003975,0010004179, 0010004534,0010004943,0010005724,0010007075,0010007495, 0010008083,0010008279,0010008488,0010008692,0010008751, 0010009439,0010010330,0010011663,0010012262,0010012543, 0010012575,0010013477,0010014195,0010015876,0010016684, 0010017677,0010018443,0010019213,0010019403,0010019646 0010020446,0010020695,0010021115,0010021159,0010021916, 0010022698,0010024937,0010026652,0010030656,0010031115, 0010031654,0010031760,0010033685,0010034046,0010034303, 0010035140,0010037655,0010038043,0010038117,0010038168, 0010038622,0010039907,0010042346,0010044178,0010046528, 0010046756,0010048385,0010049308,0010049625,0010049854, 0010050309,0010051869,0010052193,0010052645,0010052927, 0010053024,0010054182,0010055882,001
摘要(jointFit.copd)摘要中的Fehler(jointFit.copd):Objekt'infeFit.copd'nicht gefunden
事情是:我检查了数据,事件发生后没有测量结果。
我在这里缺少什么?
答案 0 :(得分:2)
在运行模型之前,尝试在DATA
上对patnr
进行排序。我可以通过制作未排序的DATA
来引发aids
示例中newid
的错误。
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)
当我查看code for JM on github时,我想到了这一点。由于错误消息是在jointModel.R的第139行打印的,因此我查看了如何在该行上方定义事物,并得出结论:假设对id变量进行排序的数据集。因此,虽然DATA
中的任何主题都没有违反条件,但订单会在代码中被扰乱。在没有可重复的示例的情况下,我的第一个提示是问题中给出的数据集的前20行有ID 0010000343,0010000873,0010002412,但是发布的错误消息列出了按排序顺序的ID为0010000343, 0010000695 ,0010000873,0010002412 - 表示DATA
未在patnr
模型中列出的id变量(lme()
)上排序。原始aids
示例按ID(patient
)排序。