将中介包与 lme4 模型一起使用时出错:中介模型尚未实现 - 之前的答案对我不起作用

Car*_*nse 3 r lme4

您好,我是 R 和这个论坛的新手。\n我遇到了与之前的发帖者相同的问题,但我的问题没有得到解决。当我尝试使用包 lme4 和中介运行多级中介模型时,我收到消息:“中介模型尚未实现”。

\n\n

我的数据:

\n\n
data.frame\':    25383 obs. of  115 variables:\n$ PID                        : num  1 1 1 1 1 1 1 1 1 1 ...\n$ T0_AGE                     : num  66.6 79.7 85.6 87 79.9 67.4 80 72 80.1 \n68$ T0_ASEXE                 : Factor w/ 2 levels "Male","Female": 1 1...\n$ T0_ALIVING_R               : num  0 0 0 0 1 0 0 0 1 0 ...\n$ T0_educationcat            : Factor w/ 3 levels "high","middle",..\n$ FI_morbidity_corrected     : num  0.0625 0 0.125 0.0625 0.0625 0.125 \xe2\x80\xa6\xe2\x80\xa6\n$ FI_SRH                     : num  0.5 0.375 0.75 0.625 0.375\xe2\x80\xa6."\n
Run Code Online (Sandbox Code Playgroud)\n\n

我想看看如何调解和FI_morbidity_corrected之间的关系。我正在为(项目 ID)指定随机截距,因为数据聚集在不同的研究/项目中。我正在控制混杂因素T0_educationcatFI_SRHPIDT0_ASEXE + T0_AGE + T0_ALIVING_R

\n\n
med.fit <- lmer(FI_morbidity_corrected~T0_educationcat + T0_ASEXE + T0_AGE + \nT0_ALIVING_R + (1|PID),data=topicsmds)\nout.fit <- lmer(FI_SRH~FI_morbidity_corrected + T0_educationcat + T0_ASEXE + \nT0_AGE + T0_ALIVING_R + (1|PID),data=topicsmds)\n
Run Code Online (Sandbox Code Playgroud)\n\n

这可行,但是:

\n\n
med23.out <- mediate(med.fit, out.fit, treat = "T0_educationcat", mediator = \n"FI_morbidity_corrected", control.value = "high", treat.value = "middle", \nsims = 100)\nsummary(med23.out)\n
Run Code Online (Sandbox Code Playgroud)\n\n

\n\n
med24.out <- mediate(med.fit, out.fit, treat = "T0_educationcat", mediator = \n"FI_morbidity_corrected", control.value = "high", treat.value = "low", sims \n= 100)\nsummary(med24.out)\n
Run Code Online (Sandbox Code Playgroud)\n\n

给我错误:

\n\n
\n

中介模型尚未实现

\n
\n\n

我已经按照建议加载了 lme4 包library(lme4),但仍然出现此错误。

\n\n

inherits(mediatorModel, "merMod")返回 TRUE

\n\n

getCall(mediatorModel)[[1]]返回 lme4::lmer

\n\n

谢谢!

\n

小智 10

您正在加载包裹lmerTest吗?如果是这样,class(med.fit[[1]])则返回merModLmerTest而不是lmerMod- 但中介包期望后者。卸载lmerTest就可以解决问题。