如何在 R 中拟合序数(3 个级别)逻辑混合效应模型?我想它会像 glmer 一样,除了三个结果级别。
数据结构
patientid Viral_load Adherence audit_score visit
1520 0 optimal nonhazardous 1
1520 0 optimal nonhazardous 2
1520 0 optimal hazardous 3
1526 1 suboptimal hazardous 1
1526 0 optimal hazardous 2
1526 0 optimal hazardous 3
1568 2 suboptimal hazardous 1
1568 2 suboptimal nonhazardous 2
1568 2 suboptimal nonhazardous 3
病毒载量(感兴趣的结果)由三个级别(0、1、2)组成,依从性 - 最佳/次优,审核分数无危险/危险,以及 3 次就诊。
这是一个使用广义混合效果模型代码来展示模型外观的示例。
library (lme4)
test <- glmer(viral_load ~ audit_score + adherence + (1|patientid) + (1|visit), data = df,family = binomial)
summary (test)
此代码的结果不正确,因为它采用 Viral_load 的二项式结果。
我希望我的问题很清楚。
你可以尝试一下
ordinal
包的 clmm
功能:
fmm1 <- clmm(rating ~ temp + contact + (1|judge), data = wine)
summary(fmm1)
Cumulative Link Mixed Model fitted with the Laplace approximation
formula: rating ~ temp + contact + (1 | judge)
data: wine
link threshold nobs logLik AIC niter max.grad cond.H
logit flexible 72 -81.57 177.13 332(999) 1.02e-05 2.8e+01
Random effects:
Groups Name Variance Std.Dev.
judge (Intercept) 1.279 1.131
Number of groups: judge 9
Coefficients:
Estimate Std. Error z value Pr(>|z|)
tempwarm 3.0630 0.5954 5.145 2.68e-07 ***
contactyes 1.8349 0.5125 3.580 0.000344 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Threshold coefficients:
Estimate Std. Error z value
1|2 -1.6237 0.6824 -2.379
2|3 1.5134 0.6038 2.507
3|4 4.2285 0.8090 5.227
4|5 6.0888 0.9725 6.261
我非常确定该链接是逻辑的,因为使用更灵活的 clmm2 函数运行相同的模型,其中默认链接被记录为逻辑的,我得到了相同的结果。
我怀疑您可以将 LHS 保留为整数,并仅使用
glmer
即可获得可解释的结果。我知道,在使用线性回归机制时,该策略可以作为“趋势的线性测试”。您将无法估计每个增量的单独对数优势比。