【发布时间】:2017-01-10 11:54:23
【问题描述】:
我有一个包含大约 300 名患者的多级重复测量数据集,每个患者有多达 10 次重复测量来预测肌钙蛋白升高。数据集中还有其他变量,但我没有在这里包含它们。
我正在尝试使用nlme 创建一个随机斜率、随机截距模型,其中患者之间的效果不同,并且不同患者的时间效果不同。当我尝试引入一阶协方差结构以允许测量值因时间而相关时,我收到以下错误消息。
Error in `coef<-.corARMA`(`*tmp*`, value = value[parMap[, i]]) : Coefficient matrix not invertible
我已经包含了我的代码和数据集的一个示例,如果有任何智慧的话,我将不胜感激。
#baseline model includes only the intercept. Random slopes - intercept varies across patients
randomintercept <- lme(troponin ~ 1,
data = df, random = ~1|record_id, method = "ML",
na.action = na.exclude,
control = list(opt="optim"))
#random intercept and time as fixed effect
timeri <- update(randomintercept,.~. + day)
#random slopes and intercept: effect of time is different in different people
timers <- update(timeri, random = ~ day|record_id)
#model covariance structure. corAR1() first order autoregressive covariance structure, timepoints equally spaced
armodel <- update(timers, correlation = corAR1(0, form = ~day|record_id))
Error in `coef<-.corARMA`(`*tmp*`, value = value[parMap[, i]]) : Coefficient matrix not invertible
数据:
record_id day troponin
1 1 32
2 0 NA
2 1 NA
2 2 NA
2 3 8
2 4 6
2 5 7
2 6 7
2 7 7
2 8 NA
2 9 9
3 0 14
3 1 1167
3 2 1935
4 0 19
4 1 16
4 2 29
5 0 NA
5 1 17
5 2 47
5 3 684
6 0 46
6 1 45440
6 2 47085
7 0 48
7 1 87
7 2 44
7 3 20
7 4 15
7 5 11
7 6 10
7 7 11
7 8 197
8 0 28
8 1 31
9 0 NA
9 1 204
10 0 NA
10 1 19
【问题讨论】:
标签: r covariance multi-level nlme