【发布时间】:2017-11-20 03:31:03
【问题描述】:
您好,我是 R 和这个论坛的新手。 我和a previous poster 有同样的问题,但我的问题没有得到解决。当我尝试使用包 lme4 和中介运行多级中介模型时,我收到消息:“中介模型尚未实现”。
我的数据:
data.frame': 25383 obs. of 115 variables:
$ PID : num 1 1 1 1 1 1 1 1 1 1 ...
$ T0_AGE : num 66.6 79.7 85.6 87 79.9 67.4 80 72 80.1
68$ T0_ASEXE : Factor w/ 2 levels "Male","Female": 1 1...
$ T0_ALIVING_R : num 0 0 0 0 1 0 0 0 1 0 ...
$ T0_educationcat : Factor w/ 3 levels "high","middle",..
$ FI_morbidity_corrected : num 0.0625 0 0.125 0.0625 0.0625 0.125 ……
$ FI_SRH : num 0.5 0.375 0.75 0.625 0.375…."
我想看看FI_morbidity_corrected 如何调解T0_educationcat 和FI_SRH 之间的关系。我为PID(项目ID)指定了一个随机截距,因为数据聚集在不同的研究/项目中。我正在控制混杂因素T0_ASEXE + T0_AGE + T0_ALIVING_R
med.fit <- lmer(FI_morbidity_corrected~T0_educationcat + T0_ASEXE + T0_AGE +
T0_ALIVING_R + (1|PID),data=topicsmds)
out.fit <- lmer(FI_SRH~FI_morbidity_corrected + T0_educationcat + T0_ASEXE +
T0_AGE + T0_ALIVING_R + (1|PID),data=topicsmds)
这可行,但是:
med23.out <- mediate(med.fit, out.fit, treat = "T0_educationcat", mediator =
"FI_morbidity_corrected", control.value = "high", treat.value = "middle",
sims = 100)
summary(med23.out)
和
med24.out <- mediate(med.fit, out.fit, treat = "T0_educationcat", mediator =
"FI_morbidity_corrected", control.value = "high", treat.value = "low", sims
= 100)
summary(med24.out)
给我错误:
中介模型尚未实现
我已按照建议使用 library(lme4) 加载了 lme4 包,但仍然出现此错误。
inherits(mediatorModel, "merMod") 返回 TRUE
getCall(mediatorModel)[[1]] 返回 lme4::lmer
谢谢!
【问题讨论】: