title: How can I plot fitted models with observations when dealing with the ANOVA type of research design in R?
body: <p>I am learning how to apply a multilevel modelling to traditional ANOVA research designs.
  I would like to plot fitted regression lines for each treatment using ggplot2. I would like to plot regression lines based on models I fitted, not let ggplot2 to plot since I would like to see how estimations differ based on changing models. I am aware that I can calculate coefficients and slopes by myself, but because the model is relatively complicated, I am looking for ways to plot more easily.</p>
  
  <p>This is the sample code for the type of research design I am dealing with. 
  I found that the sjPlot package (<a href="http://www.strengejacke.de/sjPlot/sjp.lm/" rel="nofollow noreferrer">http://www.strengejacke.de/sjPlot/sjp.lm/</a>) provides very nice plots, which shows the regression lines for each treatment over each test timing and actual observations on a scatter plot. This is exactly what I would like to make with ggplot.</p>
  
  <pre><code> require(tidyverse)
   require(sjPlot)
   set.seed (100)
   dat &lt;- data_frame(
      participant_id = c(c(1:15), c(1:15)),
      treatment = c(sample (letters [1:3], 15, replace = T), sample (letters [1:3], 15, replace = T)),
      test_timing = c(sample(letters [1:3], 15, replace = T),sample(letters [1:3], 15, replace = T)),
      learning_gain = (runif(30, min = 1, max = 20))
  )
  
  fit &lt;- lm (learning_gain ~ treatment * test_timing -1, data = dat)
  sjp.lm(fit, type = "pred", 
  vars = c("test_timing", "treatment"),facet.grid = F)
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/ohPEU.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ohPEU.png" alt="enter image description here"></a></p>
  
  <p>Or, something like this:</p>
  
  <pre><code> sjp.lm(fit, type = "pred", 
      vars = c("test_timing", "treatment"),facet.grid = T)
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/QlhzG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/QlhzG.png" alt="enter image description here"></a></p>
  
  <p>I would really appreciate it if you could teach me how I can make a plot similar to this image using the ggplot2 package. Thank you!</p>