A package to estimate non-linear hierarchical models using the
variational algorithms described in Goplerud (2022a) and in Goplerud
(2022b). It also provides the option to improve an initial
approximation using marginally augmented variational Bayes (MAVB) also
described in Goplerud (2022a). It can be installed from CRAN or the
most-to-update version can be installed using devtools
.
# CRAN
install.packages("vglmer")
# Up-to-Date GitHub Version
library(devtools)
devtools::install_github("mgoplerud/vglmer", dependencies = TRUE)
At present, it can fit logistic, linear, and negative binomial outcomes with an arbitrary number of random effects. Details on negative binomial inference can be found here and are more experimental at the moment.
This package accepts “standard” glmer syntax of the form:
vglmer(formula = y ~ x + (x | g), data = data, family = 'binomial')
Splines can be estimated using v_s(x)
, similar to the
functionality in mgcv
, although with many fewer
options.
vglmer(formula = y ~ v_s(x) + (x | g), data = data, family = 'binomial')
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 (2022a) correspond to strong
,
partial
, and weak
. The default is
strong
which correspond to the strongest (worst)
approximation. If the variance of the parameters is of interest, then
weak
will return better results.
Please make an issue on GitHub with any concerns you have.