【问题标题】:covariance structure for multilevel modelling多级建模的协方差结构
【发布时间】: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


    【解决方案1】:

    如果您将优化器更改为“nlminb”(或者至少它适用于您发布的缩减数据集),您可以适应这个。

    armodel <- update(timers, 
                  correlation = corAR1(0, form = ~day|record_id),
                  control=list(opt="nlminb"))
    

    但是,如果您查看拟合模型,您会发现存在问题 - 估计的 AR1 参数为 -1,并且随机截距和斜率项与 r=0.998 相关。

    我认为问题在于数据的性质。大部分数据似乎都在 10-50 的范围内,但也有一个或两个数量级的偏移(例如个别 6 个,最多大约 45000 个)。可能很难用模型来拟合这种尖峰的数据。我会强烈建议对您的数据进行日志转换;标准诊断图 (plot(randomintercept)) 如下所示:

    而适合对数刻度

    rlog <- update(randomintercept,log10(troponin) ~ .)
    plot(rlog)
    

    有点更合理,尽管仍有一些异方差的证据。

    AR+随机斜率模型拟合OK:

    ar.rlog <- update(rlog,
                  random = ~day|record_id,
                  correlation = corAR1(0, form = ~day|record_id))
    ## Linear mixed-effects model fit by maximum likelihood
    ## ...
    ## Random effects:
    ##  Formula: ~day | record_id
    ##  Structure: General positive-definite, Log-Cholesky parametrization
    ##             StdDev    Corr  
    ## (Intercept) 0.1772409 (Intr)
    ## day         0.6045765 0.992 
    ## Residual    0.4771523       
    ##
    ##  Correlation Structure: ARMA(1,0)
    ##  Formula: ~day | record_id 
    ##  Parameter estimate(s):
    ##       Phi1 
    ## 0.09181557 
    ## ...
    

    快速浏览intervals(ar.rlog) 表明自回归参数的置信区间为 (-0.52,0.65),因此可能不值得保留...

    随着模型中的随机斜率,异方差似乎不再有问题......

    plot(rlog,sqrt(abs(resid(.)))~fitted(.),type=c("p","smooth"))
    

    【讨论】:

    • 非常感谢您的帮助。是的,数据是如此尖刻,你完全正确,对它进行日志转换确实使它看起来更好。我不知道如何将图像添加到这些 cmets 中,但整个数据集残差大致看起来像你的。我已将优化器更改为 nlminb,但现在我无法让模型收敛。你有什么进一步的建议吗?非常感谢,Annemarie nlminb 问题,收敛错误代码 = 1 条消息 = 没有收敛就达到迭代限制 (10)
    • ?lmeControl,(尤其是maxItermsMaxIter),虽然它可能无法解决问题。
    • 非常感谢@Ben Bolker
    • 虽然表达了赞赏,但 StackOverflow 弃用了 using comments to say "thank you";如果此答案有用,您可以投票(如果您有足够的声誉),并且无论如何如果它令人满意地回答了您的问题,我们鼓励您单击复选标记以接受它。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-04-27
    • 2018-08-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-02-06
    相关资源
    最近更新 更多