Learn R Programming

rstanarm (version 2.9.0-1)

stan_glmer: Bayesian generalized linear models with group-specific terms via Stan

Description

Bayesian inference for GLMs with group-specific coefficients that have unknown covariance matrices with flexible priors.

Usage

stan_glmer(formula, data = NULL, family = gaussian, subset, weights,
  na.action = getOption("na.action", "na.omit"), offset, contrasts = NULL,
  ..., prior = normal(), prior_intercept = normal(),
  prior_ops = prior_options(), prior_covariance = decov(),
  prior_PD = FALSE, algorithm = c("sampling", "meanfield", "fullrank"),
  adapt_delta = NULL, QR = FALSE)

stan_lmer(...)

stan_glmer.nb(..., link = "log")

Arguments

formula, data, family
Same as for glmer.
subset, weights, offset
Same as glm.
na.action, contrasts
Same as glm, but rarely specified.
...
For stan_glmer, further arguments passed to sampling (e.g. iter, chains, cores, etc.) or to vb (i
prior
Prior for coefficients. Can be NULL to omit a prior and see priors otherwise.
prior_intercept
Prior for intercept. Can be NULL to omit a prior and see priors otherwise. (Note: the prior distribution for the intercept is set so it applies to the value when all predictors
prior_ops
Additional options related to prior distributions. Can be NULL to omit a prior on the dispersion and see prior_options otherwise.
prior_covariance
Cannot be NULL; see decov for more information about the default arguments.
prior_PD
A logical scalar (defaulting to FALSE) indicating whether to draw from the prior predictive distribution instead of conditioning on the outcome.
algorithm
Character string (possibly abbreviated) indicating the estimation approach to use. Can be "sampling" for MCMC (the default), "optimizing" for optimization, "meanfield" for variational inference with independent norm
adapt_delta
Only relevant if algorithm="sampling". See adapt_delta for details.
QR
A logical scalar (defaulting to FALSE) but if TRUE applies a scaled qr decomposition to the design matrix, $X = Q^\ast R^\ast$, where $Q^\ast = Q \sqrt{n-1}$ and $R^\ast = \frac{1}{\s
link
For stan_glmer.nb only, the link function to use. See neg_binomial_2.

Value

  • A stanreg object is returned for stan_glmer, stan_lmer, stan_glmer.nb.

Details

The stan_glmer function is similar in syntax to glmer but rather than performing (restricted) maximum likelihood estimation of generalized linear models, Bayesian estimation is performed via MCMC. The Bayesian model adds independent priors on the regression coefficients (in the same way as stan_glm) and priors on the terms of a decomposition of the covariance matrices of the group-specific parameters. See priors for more information about the priors. The stan_lmer function is equivalent to stan_glmer with family = gaussian(link = "identity"). The stan_glmer.nb function, which takes the extra argument link, is a simple wrapper for stan_glmer with family = neg_binomial_2(link).

References

Gelman, A. and Hill, J. (2007). Data Analysis Using Regression and Multilevel/Hierarchical Models. Cambridge University Press, Cambridge, UK. (Ch. 11-15)

See Also

stanreg-methods and glmer.

Examples

Run this code
# see help(example_model) for details on the model below
print(example_model, digits = 1)

Run the code above in your browser using DataLab