<div dir="ltr"><div><div>Hi Kentaro,<br><br></div>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.<br><br>> inherits(mediatorModel, "merMod")<br>[1] TRUE<br>> getCall(mediatorModel)[[1]]<br>lme4::lmer<br><br></div><div>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!<br><br></div><div>Best,<br>Hause<br></div><div><br><br></div><div><br></div><br></div><div class="gmail_extra"><br><div class="gmail_quote">On 15 August 2016 at 13:46, Kentaro Hirose <span dir="ltr"><<a href="mailto:hirose1981@gmail.com" target="_blank">hirose1981@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi Hause, <div><br></div><div>The error message "<span style="font-size:14px">mediator model is not yet implemented</span>" 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? </div><div><br></div><div>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):</div><div><br></div><div>-----------------------</div><div><div>library(mediation)</div><div>library(lme4)</div></div><div><br></div><div>mediatorModel <- lmer(depress1 ~ treat + age + (1|job_disc), data = jobs)</div><div>outcomeModel <- lmer(econ_hard ~ depress1 + treat + age + (1|job_disc), data = jobs)</div><div><br></div><div>mediation <- mediate(model.m = mediatorModel, model.y = outcomeModel, sims = 100, robustSE = F, treat = "treat", mediator = "depress1")</div><div>summary(mediation) </div><div>-----------------------<br></div><div><br></div><div>Best,</div><div>Kentaro</div><div><br></div><div><br></div><div> </div></div><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="h5">2016-08-16 1:53 GMT+09:00 Hause Lin <span dir="ltr"><<a href="mailto:hause.lin@mail.utoronto.ca" target="_blank">hause.lin@mail.utoronto.ca</a>></span>:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5"><div dir="ltr"><div>Hi,<br><br></div>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: <br><br>Error in mediation::mediate(model.m = mediatorModel, model.y = outcomeModel, : <br> mediator model is not yet implemented<br><div><br></div><div>Below are my models. Can anyone tell why I'm getting that error message?<br></div><div><br>mediatorModel <- lmer(m ~ x1 + x2 + (1 | id), data = df)<br><br>outcomeModel <- lmer(y ~ m + x1 + x2 + (1 | id), data = df)<br><br>mediation <- mediate(model.m = mediatorModel, model.y = outcomeModel, sims = 100, robustSE = F, treat = "x2", mediator = "m")<br><br></div><div>I really appreciate any help anyone can provide. Thanks!<br><br></div><div>Best,<br>Hause<br></div><div><br></div></div>
<br></div></div>______________________________<wbr>_________________<br>
Mediation-information mailing list<br>
<a href="mailto:Mediation-information@lists.r-forge.r-project.org" target="_blank">Mediation-information@lists.r-<wbr>forge.r-project.org</a><br>
<a href="https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/mediation-information" rel="noreferrer" target="_blank">https://lists.r-forge.r-projec<wbr>t.org/cgi-bin/mailman/listinfo<wbr>/mediation-information</a><br></blockquote></div><br></div>
</blockquote></div><br></div>