title: Error using mediation package with lme4 model: mediator model is not yet implemented - previous answer does not work for me
body: <p>Hi I am new to R and this forum.
  I have the same problem as <a href="https://stackoverflow.com/questions/41253257/error-using-mediation-package-with-lme4-model-mediator-model-is-not-yet-impleme">a previous poster</a>, 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. </p>
  
  <p>My data:</p>
  
  <pre><code>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…."
  </code></pre>
  
  <p>I am trying to see how <code>FI_morbidity_corrected</code> mediates the relationship between <code>T0_educationcat</code> and <code>FI_SRH</code>. I'm specifying a random intercept for <code>PID</code> (project ID) as data is clustered in different studies/projects. I am controlling for confounders <code>T0_ASEXE + T0_AGE + T0_ALIVING_R</code></p>
  
  <pre><code>med.fit &lt;- lmer(FI_morbidity_corrected~T0_educationcat + T0_ASEXE + T0_AGE + 
  T0_ALIVING_R + (1|PID),data=topicsmds)
  out.fit &lt;- lmer(FI_SRH~FI_morbidity_corrected + T0_educationcat + T0_ASEXE + 
  T0_AGE + T0_ALIVING_R + (1|PID),data=topicsmds)
  </code></pre>
  
  <p>This works, but then:</p>
  
  <pre><code>med23.out &lt;- mediate(med.fit, out.fit, treat = "T0_educationcat", mediator = 
  "FI_morbidity_corrected", control.value = "high", treat.value = "middle", 
  sims = 100)
  summary(med23.out)
  </code></pre>
  
  <p>and</p>
  
  <pre><code>med24.out &lt;- mediate(med.fit, out.fit, treat = "T0_educationcat", mediator = 
  "FI_morbidity_corrected", control.value = "high", treat.value = "low", sims 
  = 100)
  summary(med24.out)
  </code></pre>
  
  <p>Give me the error:</p>
  
  <blockquote>
    <p>mediator model is not yet implemented</p>
  </blockquote>
  
  <p>I have loaded the lme4 pakage using <code>library(lme4)</code> as suggested, but still get this error.</p>
  
  <p><code>inherits(mediatorModel, "merMod")</code> returned TRUE</p>
  
  <p><code>getCall(mediatorModel)[[1]]</code> returned lme4::lmer</p>
  
  <p>Thanks!</p>