Description Usage Arguments Details Value References See Also Examples

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | ```
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 `data` is specified (and is a data frame) many post-estimation
functions (including `update` , `loo` , `kfold` ) are not
guaranteed to work properly. | |||||||||||

`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—
| |||||||||||

`prior_intercept` |
The prior distribution for the intercept.
| |||||||||||

`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 |

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
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 wrapper for `stan_glmer`

with ```
family =
neg_binomial_2(link)
```

.

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 variance-covariance
matrix of the group-specific deviations from the common parameters is
called `Sigma`

, even if this variance-covariance matrix only has
one row and one column (in which case it is just the group-level variance).

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

Muth, C., Oravecz, Z., and Gabry, J. (2018)
User-friendly Bayesian regression modeling: A tutorial with rstanarm and shinystan.
*The Quantitative Methods for Psychology*. 14(2), 99–119.
https://www.tqmp.org/RegularArticles/vol14-2/p099/p099.pdf

`stanreg-methods`

and
`glmer`

.

The vignette for `stan_glmer`

and the *Hierarchical
Partial Pooling* vignette. http://mc-stan.org/rstanarm/articles/

1 2 3 | ```
# see help(example_model) for details on the model below
if (!exists("example_model")) example(example_model)
print(example_model, digits = 1)
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.