您好,我是 R 和这个论坛的新手。\n我遇到了与之前的发帖者相同的问题,但我的问题没有得到解决。当我尝试使用包 lme4 和中介运行多级中介模型时,我收到消息:“中介模型尚未实现”。
\n\n我的数据:
\n\ndata.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."\nRun Code Online (Sandbox Code Playgroud)\n\n我想看看如何调解和FI_morbidity_corrected之间的关系。我正在为(项目 ID)指定随机截距,因为数据聚集在不同的研究/项目中。我正在控制混杂因素T0_educationcatFI_SRHPIDT0_ASEXE + T0_AGE + T0_ALIVING_R
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)\nRun Code Online (Sandbox Code Playgroud)\n\n这可行,但是:
\n\nmed23.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)\nRun Code Online (Sandbox Code Playgroud)\n\n和
\n\nmed24.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)\nRun Code Online (Sandbox Code Playgroud)\n\n给我错误:
\n\n\n\n\n中介模型尚未实现
\n
我已经按照建议加载了 lme4 包library(lme4),但仍然出现此错误。
inherits(mediatorModel, "merMod")返回 TRUE
getCall(mediatorModel)[[1]]返回 lme4::lmer
谢谢!
\n小智 10
您正在加载包裹lmerTest吗?如果是这样,class(med.fit[[1]])则返回merModLmerTest而不是lmerMod- 但中介包期望后者。卸载lmerTest就可以解决问题。