title: Prediction with lme4 on new levels
body: <p>I'm trying to fit a mixed effects model and then use that model to generate estimates on a new dataset that may have different levels.  I expected that the estimates on a new dataset would use the mean value of the estimated parameters, but that doesn't seem to be the case.  Here's a minimum working example:</p>
  
  <pre><code>library(lme4)
  d = data.frame(x = rep(1:10, times = 3),
                 y = NA,
                 grp = rep(1:3, each = 10))
  d$y[d$grp == 1] = 1:10 + rnorm(10)
  d$y[d$grp == 2] = 1:10 * 1.5 + rnorm(10)
  d$y[d$grp == 3] = 1:10 * 0.5 + rnorm(10)
  fit = lmer(y ~ (1+x)|grp, data = d)
  newdata = data.frame(x = 1:10, grp = 4)
  predict(fit, newdata = newdata, allow.new.levels = TRUE)
  </code></pre>
  
  <p>In this example, I'm essentially defining three groups with different regression equations (slopes of 1, 1.5 and 0.5).  However, when I try to predict on a new dataset with an unseen level, I get a constant estimate.  I would have expected the expected value of the slope and intercept to be used to generate predictions for this new data.  Am I expecting the wrong thing?  Or, what am I doing wrong with my code?</p>