Learn R Programming

vglmer: Variational Generalized Linear Mixed Effects Regression

A package to estimate non-linear hierarchical models using the variational algorithms described in Goplerud (2022) and in Goplerud (2024). It also provides the option to improve an initial approximation using marginally augmented variational Bayes (MAVB) also described in Goplerud (2022). 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)

If you are interested in using partially factorized variational inference (Goplerud, Papaspiliopoulos, and Zanella 2023), please switch to the collapsed branch and install that version of the package. There are some important differences with this main branch, especially in terms of some vglmer_control naming conventions. This branch will be eventually integrated into the main package.

At present, vglmer 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 (2022) 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.

Copy Link

Version

Install

install.packages('vglmer')

Monthly Downloads

1,820

Version

1.0.5

License

GPL (>= 2)

Issues

Pull Requests

Stars

Forks

Maintainer

Max Goplerud

Last Published

September 12th, 2024

Functions in vglmer (1.0.5)

simple_EM

Simple EM algorithm for starting values.
vglmer_control

Control for vglmer estimation
LinRegChol

Linear Regression by Cholesky
MAVB

Perform MAVB after fitting vglmer
v_s

Create splines for use in vglmer
var_mat

Variance of Rows or Columns of Matrices
sl_vglmer

SuperLearner with (Variational) Hierarchical Models
posterior_samples.vglmer

Draw samples from the variational distribution
vglmer_predict

Predict after vglmer
smooth.construct.randwalk.smooth.spec

Constructor for random walk smooth
vglmer-class

Generic Functions after Running vglmer
vglmer

Variational Inference for Hierarchical Generalized Linear Models
formOmega

Code from Wand and Ormerod (2008) Found here here: 10.1111/j.1467-842X.2008.00507.x
Predict.matrix.randwalk.smooth

Predict Methods for random walk smooth
custom_glmer_samples

Get samples from GLMER
reexports

Objects exported from other packages
fallback_interpret.gam0

Interpret a vglmer formula for splines
fallback_subbars

To be used if subbars fails, usually when there is an argument to v_s ; adapted from lme4