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 = cauchy(0, 5), 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 = cauchy(0, 5), 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 = cauchy(0, 5), prior_covariance = decov(), prior_PD = FALSE, algorithm = c("sampling", "meanfield", "fullrank"), adapt_delta = NULL, QR = FALSE)glmer.glm.glm, but rarely
specified.prior should be a call to one of the various functions provided by
rstanarm for specifying priors. The subset of these functions that
can be used for the prior on the coefficients can be grouped into several
"families":| Family |
| Functions |
| Student t family |
normal, student_t, cauchy |
| Hierarchical shrinkage family |
hs, hs_plus |
| Laplace family |
laplace, lasso |
| Product normal family |
product_normal |
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 can be set to NULL, although this is rarely a good
idea.
Note: Unless QR=TRUE, if prior is from the Student t
family or Laplace family, and if the autoscale argument to the
function used to specify the prior (e.g. normal) is left at
its default and recommended value of TRUE, then the default or
user-specified prior scale(s) may be adjusted internally based on the scales
of the predictors. See the priors help page for details on
the rescaling and the prior_summary function for a summary of
the priors used for a particular model.
prior_intercept can be a call to normal, student_t or
cauchy. See the priors help page for details on
these functions. To omit a prior on the intercept ---i.e., to use a flat
(improper) uniform prior--- prior_intercept can be set to
NULL.Note: If using a dense representation of the design matrix
---i.e., if the sparse argument is left at its default value of
FALSE--- then the prior distribution for the intercept is set so it
applies to the value when all predictors are centered.
family. For Gaussian models prior_aux
controls "sigma", the error
standard deviation. For negative binomial models prior_aux controls
"reciprocal_dispersion", which is similar to the
"size" parameter of rnbinom:
smaller values of "reciprocal_dispersion" correspond to
greater dispersion. For gamma models prior_aux sets the prior on
to the "shape" parameter (see e.g.,
rgamma), and for inverse-Gaussian models it is the
so-called "lambda" parameter (which is essentially the reciprocal of
a scale parameter). Binomial and Poisson models do not have auxiliary
parameters. prior_aux can be a call to exponential to
use an exponential distribution, or normal, student_t or
cauchy, which results in a half-normal, half-t, or half-Cauchy
prior. See priors for details on these functions. To omit a
prior ---i.e., to use a flat (improper) uniform prior--- set
prior_aux to NULL.
NULL; see decov for
more information about the default arguments.FALSE) indicating
whether to draw from the prior predictive distribution instead of
conditioning on the outcome."sampling" for MCMC (the
default), "optimizing" for optimization, "meanfield" for
variational inference with independent normal distributions, or
"fullrank" for variational inference with a multivariate normal
distribution. See rstanarm-package for more details on the
estimation algorithms. NOTE: not all fitting functions support all four
algorithms.algorithm="sampling". See
adapt_delta for details.FALSE) but if TRUE
applies a scaled qr decomposition to the design matrix,
$X = Q* R*$, where $Q* =
Q (n-1)^0.5$ and $R* = (n-1)^(-0.5)
R$. The coefficients relative to $Q*$ are obtained and then
premultiplied by the inverse of $R*$ to obtain coefficients
relative to the original predictors, $X$. These transformations do not
change the likelihood of the data but are recommended for computational
reasons when there are multiple predictors. However, because when QR
is TRUE the prior argument applies to the coefficients
relative to $Q*$ (and those are not very interpretable) it is
hard to specify an informative prior. Setting QR=TRUE is therefore
only recommended if you do not have an informative prior for the regression
coefficients.FALSE) indicating
whether to use a sparse representation of the design (X) matrix.
Setting this to TRUE will likely be twice as slow, even if the
design matrix has a considerable number of zeros, but it may allow the
model to be estimated when the computer has too little RAM to
utilize a dense design matrix. If TRUE, the the design matrix
is not centered (since that would destroy the sparsity) and it is
not possible to specify both QR = TRUE and sparse = TRUE.stan_glmer.nb only, the link function to use. See
neg_binomial_2.stan_glmer, stan_lmer, stan_glmer.nb.
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).
stanreg-methods and
glmer.The vignette for stan_glmer and the Hierarchical
Partial Pooling vignette.
# see help(example_model) for details on the model below
if (!exists("example_model")) example(example_model)
print(example_model, digits = 1)
Run the code above in your browser using DataLab