These methods tidy the estimates from rstanarm
fits
(stan_glm
, stan_glmer
, etc.)
into a summary.
Fitted model object from the rstanarm package. See
stanreg-objects
.
A character vector including one or more of "fixed"
,
"ran_vals"
, or "ran_pars"
.
See the Value section for details.
If TRUE
columns for the lower (conf.low
) and upper (conf.high
) bounds of the
100*prob
% posterior uncertainty intervals are included. See
posterior_interval
for details.
See posterior_interval
.
method for computing confidence intervals ("quantile" or "HPDinterval")
For glance
, if looic=TRUE
, optional arguments to
loo.stanfit
.
Should the LOO Information Criterion (and related info) be
included? See loo.stanfit
for details. (This
can be slow for models fit to large datasets.)
All tidying methods return a data.frame
without rownames.
The structure depends on the method chosen.
When effects="fixed"
(the default), tidy.stanreg
returns
one row for each coefficient, with three columns:
The name of the corresponding term in the model.
A point estimate of the coefficient (posterior median).
A standard error for the point estimate based on
mad
. See the Uncertainty estimates section in
print.stanreg
for more details.
For models with group-specific parameters (e.g., models fit with
stan_glmer
), setting effects="ran_vals"
selects the group-level parameters instead of the non-varying regression
coefficients. Addtional columns are added indicating the level
and
group
. Specifying effects="ran_pars"
selects the
standard deviations and (for certain models) correlations of the group-level
parameters.
Setting effects="auxiliary"
will select parameters other than those
included by the other options. The particular parameters depend on which
rstanarm modeling function was used to fit the model. For example, for
models fit using stan_glm
the overdispersion
parameter is included if effects="aux"
, for
stan_lm
the auxiliary parameters include the residual
SD, R^2, and log(fit_ratio), etc.
glance
returns one row with the columns
The algorithm used to fit the model.
The posterior sample size (except for models fit using optimization).
The number of observations used to fit the model.
The square root of the estimated residual variance, if
applicable. If not applicable (e.g., for binomial GLMs), sigma
will
be given the value 1
in the returned object.
If looic=TRUE
, then the following additional columns are also
included:
The LOO Information Criterion.
The expected log predictive density (elpd_loo = -2 *
looic
).
The effective number of parameters.
summary,stanfit-method
if (require("rstanarm")) {
if (FALSE) {
#' ## original model
fit <- stan_glmer(mpg ~ wt + (1|cyl) + (1+wt|gear), data = mtcars,
iter = 300, chains = 2)
}
## load example data
fit <- readRDS(system.file("extdata", "rstanarm_example.rds", package="broom.mixed"))
# non-varying ("population") parameters
tidy(fit, conf.int = TRUE, prob = 0.5)
tidy(fit, conf.int = TRUE, conf.method = "HPDinterval", prob = 0.5)
# hierarchical sd & correlation parameters
tidy(fit, effects = "ran_pars")
# group-specific deviations from "population" parameters
tidy(fit, effects = "ran_vals")
# glance method
glance(fit)
if (FALSE) {
glance(fit, looic = TRUE, cores = 1)
}
} ## if require("rstanarm")
#> Loading required package: rstanarm
#> Warning: there is no package called ‘rstanarm’