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
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.
format_vglmer to parse all parameters into a single data.frame. Estimation can be controlled via the numerous arguments to
vglmer_control. At the moment, Schemes I, II, and III in Goplerud (2020) correspond to
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.