stan_glmer.Rd
Bayesian inference for GLMs with groupspecific coefficients that have unknown covariance matrices with flexible priors.
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_aux = exponential(), prior_covariance = decov(), prior_PD = FALSE, algorithm = c("sampling", "meanfield", "fullrank"), adapt_delta = NULL, QR = FALSE, sparse = FALSE) stan_lmer(formula, data = NULL, subset, weights, na.action = getOption("na.action", "na.omit"), offset, contrasts = NULL, ..., prior = normal(), prior_intercept = normal(), prior_aux = exponential(), prior_covariance = decov(), prior_PD = FALSE, algorithm = c("sampling", "meanfield", "fullrank"), adapt_delta = NULL, QR = FALSE) stan_glmer.nb(formula, data = NULL, subset, weights, na.action = getOption("na.action", "na.omit"), offset, contrasts = NULL, link = "log", ..., prior = normal(), prior_intercept = normal(), prior_aux = exponential(), prior_covariance = decov(), prior_PD = FALSE, algorithm = c("sampling", "meanfield", "fullrank"), adapt_delta = NULL, QR = FALSE)
formula, data  Same as for 


family  Same as for 

subset, weights, offset  Same as 

na.action, contrasts  Same as 

...  For 

prior  The prior distribution for the regression coefficients.
See the priors help page for details on the families and
how to specify the arguments for all of the functions in the table above.
To omit a prior i.e., to use a flat (improper) uniform prior
Note: Unless 

prior_intercept  The prior distribution for the intercept.
Note: If using a dense representation of the design matrix
i.e., if the 

prior_aux  The prior distribution for the "auxiliary" parameter (if
applicable). The "auxiliary" parameter refers to a different parameter
depending on the


prior_covariance  Cannot be 

prior_PD  A logical scalar (defaulting to 

algorithm  A string (possibly abbreviated) indicating the
estimation approach to use. Can be 

adapt_delta  Only relevant if 

QR  A logical scalar defaulting to 

sparse  A logical scalar (defaulting to 

link  For 
A stanreg object is returned
for stan_glmer, stan_lmer, stan_glmer.nb
.
A list with classes stanreg
, glm
, lm
,
and lmerMod
. The conventions for the parameter names are the
same as in the lme4 package with the addition that the standard
deviation of the errors is called sigma
and the variancecovariance
matrix of the groupspecific deviations from the common parameters is
called Sigma
, even if this variancecovariance matrix only has
one row and one column (in which case it is just the grouplevel variance).
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 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
groupspecific 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 wrapper for stan_glmer
with family =
neg_binomial_2(link)
.
Gelman, A. and Hill, J. (2007). Data Analysis Using Regression and Multilevel/Hierarchical Models. Cambridge University Press, Cambridge, UK. (Ch. 1115)
Muth, C., Oravecz, Z., and Gabry, J. (2018) Userfriendly Bayesian regression modeling: A tutorial with rstanarm and shinystan. The Quantitative Methods for Psychology. 14(2), 99119. https://www.tqmp.org/RegularArticles/vol142/p099/p099.pdf
stanregmethods
and
glmer
.
The vignette for stan_glmer
and the Hierarchical
Partial Pooling vignette. http://mcstan.org/rstanarm/articles/
# see help(example_model) for details on the model below if (!exists("example_model")) example(example_model) print(example_model, digits = 1)#> stan_glmer #> family: binomial [logit] #> formula: cbind(incidence, size  incidence) ~ size + period + (1  herd) #> observations: 56 #>  #> Median MAD_SD #> (Intercept) 1.5 0.6 #> size 0.0 0.0 #> period2 1.0 0.3 #> period3 1.1 0.3 #> period4 1.6 0.4 #> #> Error terms: #> Groups Name Std.Dev. #> herd (Intercept) 0.76 #> Num. levels: herd 15 #> #>  #> * For help interpreting the printed output see ?print.stanreg #> * For info on the priors used see ?prior_summary.stanreg