Reputation: 31
Hi I am new to R and this forum. I have the same problem as a previous poster, but mine was not resolved with the answer. I get the message: "mediator model is not yet implemented" when I try to run a multilevel mediation model using package lme4 and mediation.
My data:
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…."
I am trying to see how FI_morbidity_corrected
mediates the relationship between T0_educationcat
and FI_SRH
. I'm specifying a random intercept for PID
(project ID) as data is clustered in different studies/projects. I am controlling for confounders 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)
This works, but then:
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)
and
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)
Give me the error:
mediator model is not yet implemented
I have loaded the lme4 pakage using library(lme4)
as suggested, but still get this error.
inherits(mediatorModel, "merMod")
returned TRUE
getCall(mediatorModel)[[1]]
returned lme4::lmer
Thanks!
Upvotes: 3
Views: 4133
Reputation: 303
Are you loading the package lmerTest
? If so, class(med.fit[[1]])
returns merModLmerTest
instead of lmerMod
- but the mediation package expects the latter. Unloading lmerTest
would solve the problem.
Upvotes: 11