[Mediation-information] Error message for models fitted with lmer: Mediator model not yet implemented?

Hause Lin hause.lin at mail.utoronto.ca
Mon Aug 15 20:27:49 CEST 2016


Hi Kentaro,

Thanks for your reply. After fiddling with my code and testing your toy
example, I've identified the problem. Both inherits() and getCall() return
the expected results.

> inherits(mediatorModel, "merMod")
[1] TRUE
> getCall(mediatorModel)[[1]]
lme4::lmer

The issue lies with the lmerTest package which I have loaded too. After
detaching lmerTest, your mediate function works perfectly again. Thanks so
much for your help!

Best,
Hause





On 15 August 2016 at 13:46, Kentaro Hirose <hirose1981 at gmail.com> wrote:

> Hi Hause,
>
> The error message "mediator model is not yet implemented" appears when
> the lmer model is not estimated properly. Can you check if (1)
> inherits(mediatorModel, "merMod") returns TRUE and (2)
> getCall(mediatorModel)[[1]] returns lmer?
>
> It might be also helpful to compare your model with the following toy
> example as a way to figure out the problem (e.g., data, code, etc):
>
> -----------------------
> library(mediation)
> library(lme4)
>
> mediatorModel <- lmer(depress1 ~ treat + age + (1|job_disc), data = jobs)
> outcomeModel <- lmer(econ_hard ~ depress1 + treat + age + (1|job_disc),
> data = jobs)
>
> mediation <- mediate(model.m = mediatorModel, model.y = outcomeModel, sims
> = 100, robustSE = F, treat = "treat", mediator = "depress1")
> summary(mediation)
> -----------------------
>
> Best,
> Kentaro
>
>
>
>
> 2016-08-16 1:53 GMT+09:00 Hause Lin <hause.lin at mail.utoronto.ca>:
>
>> Hi,
>>
>> I've previously used this package to fit simple linear models and it
>> worked very well. But recently I've been trying to do this with multilevel
>> models (lmer) and I'm getting this message:
>>
>> Error in mediation::mediate(model.m = mediatorModel, model.y =
>> outcomeModel,  :
>>   mediator model is not yet implemented
>>
>> Below are my models. Can anyone tell why I'm getting that error message?
>>
>> mediatorModel <- lmer(m ~ x1 + x2 + (1 | id), data = df)
>>
>> outcomeModel <- lmer(y ~ m + x1 + x2 + (1 | id), data = df)
>>
>> mediation <- mediate(model.m = mediatorModel, model.y = outcomeModel,
>> sims = 100, robustSE = F, treat = "x2", mediator = "m")
>>
>> I really appreciate any help anyone can provide. Thanks!
>>
>> Best,
>> Hause
>>
>>
>> _______________________________________________
>> Mediation-information mailing list
>> Mediation-information at lists.r-forge.r-project.org
>> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo
>> /mediation-information
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/mediation-information/attachments/20160815/7c789b55/attachment-0001.html>


More information about the Mediation-information mailing list