A while back I was helped to get correct confidence intervals for predicted probabilities in a logistic regression model: Correct interpretation of confidence interval for logistic regression?

Now, I want to do the same but for a mixed effects logistic regression. I use the glmer function in the lme4 package to build the mixed effects logistic regression. I can then use the predict function to get at probabilities; predict(glmer_model, newdata = new, type = "response").

But, in the non-mixed effects case, I was directed to predict(log_model, newdata = new, type = "link", se.fit = TRUE) to get the standard errors, the 95% intervals for the logits and transform back to probabilities. Problem is, predict.merMod does not take type = "link" and se.fit = TRUE as arguments.

I'm guessing this is not a problem of R syntax, but rather a deeper problem of standard errors for these models, but I would be grateful for any feedback between a fix to pointing out material for me to digest.

  • $\begingroup$ I'm using a model with a single fixed effect and a random intercept. I realize that the predicted probabilities and CI along the fixed effect will depend on the random intercept - in the graph, I'm intending to pick the mean intercept for presentation. $\endgroup$ Dec 3, 2020 at 23:44

1 Answer 1


There are two issues you should be aware of here.

  1. The only easy way (that I'm aware of) to compute the variances for individual predictions in a mixed model is to "condition on the estimates of the random effect variances", in other words to pretend that the variance of the intercept (in your case) is estimated without error. The authors of lme4 were too fussy to make this assumption, and there is no particularly easy way to way to do the calculation otherwise, so they simply declined to add an se.fit option.

    If you are willing to make this assumption, then the calculation is not too hard: there's a section in the GLMM FAQ devoted to it. There are also several different packages (ggeffects, sjPlot, emmeans) that implement these computations. (Note that these recipes will generally give you confidence intervals on predictions at the population level, not for individual groups; there are some further technical difficulties with combining the uncertainties in individual group offsets and the uncertainty in the fixed-effect parameters, see here.)

    If you really want confidence intervals on individual predictions without worrying about all this stuff, you can try a Bayesian MCMC approach (e.g. using the MCMCglmm or rstanarm or brms packages), which will give you samples incorporating uncertainty at all levels which you can then use to compute confidence intervals.

  2. When computing population-level predictions on the probability scale you may want to worry about the bias caused by the nonlinear (back-)transformation of an estimate that also has among-group variability, e.g. see the last section of this emmeans vignette.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.