R – Differences Between Mixed-Effects Modelling in RStan and lme4 Packages

generalized linear modellme4-nlmemixed modelmultilevel-analysisr

I've recently begun running some multilevel/hierarchical models. Initially I was using rstan/rstanarm, but then switched to the lme4 package.

Is the difference between these two packages only in the use of Bayesian priors (as in rstan) or not, as in lme4?

Best Answer

lme4 is fully frequentist, while rstanarm is fully Bayesian. That means there are more differences than just whether a prior is used. For example:

  • rstanarm reports marginal medians of the posterior density for each parameter, while lme4 reports maximum likelihood estimates (approximately analogous to the maximum a posteriori (MAP) estimator, or mode of the posterior distribution, given uninformative priors - but see this CV answer for discussion of why this is a loose analogy)
  • rstanarm reports posterior intervals based on quantiles of the marginal posterior distribution (not the more classical highest posterior density intervals), lme4 reports Wald standard errors or likelihood profile confidence intervals
  • diagnostics and convergence checking procedures are radically different.

For what it's worth,

  • brms, also based on Stan, implements a broad class of GLMMs (somewhat broader than rstanarm, I think)
  • MCMCglmm implements a broad class of Bayesian mixed models (based on older MCMC approaches rather than Hamiltonian MC)
  • the blme package implements a partly Bayesian approach to mixed models that allows for weakly or strongly informative priors, but reports MAP estimates (it builds on lme4's technology)
  • the R-INLA package (not on CRAN) uses integrated nested Laplace approximations; it also allows priors and returns MAP estimates
Related Question