Skip to content
Switch branches/tags
Go to file

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time

vglmer: Variational Generalized Linear Mixed Effects Regression Travis build status codecov Lifecycle: experimental

A package to estimate non-linear hierarchical models using the variational algorithms described in Goplerud (2020). It also provides the option to improve an initial approximation using marginally augmented variational Bayes (MAVB) also described in the same paper. It can be installed using devtools

library(devtools); devtools::install_github("mgoplerud/vglmer", dependencies = TRUE)

At present, it can fit logistic and negative binomial outcomes with an arbitrary number of random effects. Details on negative binomial inference can be found here and are more experimential at the moment.

This model accepts "standard" glmer syntax of the form:

vglmer(formula = y ~ x + (x | g), data = data, family = 'binomial')

vglmer(formula = y ~ x + (x | g), data = data, family = 'negbin')

Many standard methods from lme4 work, e.g. fixef, coef, vcov, ranef, predict. Use format_vglmer to parse all parameters into a single data.frame. Estimation can be controlled via the numerous arguments to control using vglmer_control. At the moment, Schemes I, II, and III in Goplerud (2020) correspond to strong, partial, and weak. Unless the model is extremely large, the default (weak) should be used.

The package is still "experimental" so some of the inputs and outputs may change! Please make an issue with any concerns you have.

One known issue is that it is not possible to include a random effect without a main effect (e.g. y ~ x + (b | g) will fail). This will be fixed shortly.


Variational Generalized Linear Mixed Effects Regression



No releases published


No packages published