title: plot mixed effects model in ggplot
body: <p>I am new with mixed effect models and I need your help please.
  I have plotted the below graph in ggplot:</p>
  
  <pre><code>ggplot(tempEf,aes(TRTYEAR,CO2effect,group=Myc,col=Myc)) + 
    facet_grid(~N) +
    geom_smooth(method="lm",se=T,size=1) +
    geom_point(alpha = 0.3) + 
    geom_hline(yintercept=0, linetype="dashed") +
    theme_bw()
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/Yczak.jpg" alt="enter image description here"></p>
  
  <p>However, I would like to represent a mixed effects model instead of <code>lm</code>in <code>geom_smooth</code>, so I can include <code>SITE</code>as a random effect.</p>
  
  <p>The model would be the following:</p>
  
  <pre><code>library(lme4)
  tempEf$TRTYEAR &lt;- as.numeric(tempEf$TRTYEAR)
  mod &lt;- lmer(r ~ Myc * N * TRTYEAR + (1|SITE), data=tempEf)
  </code></pre>
  
  <p>I have included <code>TRTYEAR</code>(year of treatment) because I am also interested in the patterns of the effect, that may increase or decrease over time for some groups.</p>
  
  <p>Next is my best attempt so far to extract the plotting variables out of the model, but only extracted the values for <code>TRTYEAR</code>=  5, 10 and 15.</p>
  
  <pre><code>library(effects)
  ef &lt;- effect("Myc:N:TRTYEAR", mod)
  x &lt;- as.data.frame(ef)
  &gt; x
     Myc     N TRTYEAR        fit         se       lower     upper
  1   AM  Nlow       5 0.04100963 0.04049789 -0.03854476 0.1205640
  2  ECM  Nlow       5 0.41727928 0.07342289  0.27304676 0.5615118
  3   AM Nhigh       5 0.20562700 0.04060572  0.12586080 0.2853932
  4  ECM Nhigh       5 0.24754017 0.27647151 -0.29556267 0.7906430
  5   AM  Nlow      10 0.08913042 0.03751783  0.01543008 0.1628307
  6  ECM  Nlow      10 0.42211957 0.15631679  0.11504963 0.7291895
  7   AM Nhigh      10 0.30411129 0.03615213  0.23309376 0.3751288
  8  ECM Nhigh      10 0.29540744 0.76966410 -1.21652689 1.8073418
  9   AM  Nlow      15 0.13725120 0.06325159  0.01299927 0.2615031
  10 ECM  Nlow      15 0.42695986 0.27301163 -0.10934636 0.9632661
  11  AM Nhigh      15 0.40259559 0.05990085  0.28492587 0.5202653
  12 ECM Nhigh      15 0.34327471 1.29676632 -2.20410343 2.8906529
  </code></pre>
  
  <p>Suggestions to a completely different approach to represent this analysis are welcome. I thought this question is better suited for stackoverflow because it’s about the technicalities in R rather than the statistics behind. Thanks</p>