title: Plot regression line of a linear mixed model taking into account other variables and random effects?
body: <p>I have a model with several fixed and random variables.<br>
  Here is the code:</p>
  
  <pre><code>model1&lt;-lmer(dep ~ pred + sex + age + heat + (1|ID) + (1|year),data=data)
  </code></pre>
  
  <p>So, by running a ggplot I get this graph  </p>
  
  <p><img src="https://i.stack.imgur.com/2vy8x.png" alt="ggplot dep &amp; pred"></p>
  
  <p>However, the ggplot, and the <code>geom_smooth()</code> function will only plot the slope and confidence intervals calculated between <code>dep</code> and <code>pred</code>.<br>
  <strong>But it will not take into account the other factors, including random terms</strong></p>
  
  <p>Indeed, with the code<br>
  <code>Effect("pred",model1)</code>  </p>
  
  <p>I get a different and probably real slope</p>
  
  <pre><code>pred effect
  
          600        1000        2000        3000        4000 
  -0.14747707 -0.10876855 -0.01199725  0.08477404  0.18154534
  </code></pre>
  
  <p>Is there a way to plot the slope and the real confidence interval area of a <code>lmer</code>?</p>
  
  <p><strong>UPDATE:</strong> I was able to get a graph with the good coordinates and confidence intervals using <code>plot(effect("pred",model1))</code>
  And this is how looks like:  </p>
  
  <p><img src="https://i.stack.imgur.com/sPbvt.png" alt="new plot right coordinates"></p>
  
  <p>But how can I now make this graph look decent? Or how can I plot this in ggplot or similar so that I can modify everything?</p>