broom (version 0.4.1)

rstanarm_tidiers: Tidying methods for an rstanarm model

Description

These methods tidy the estimates from stanreg-objects (fitted model objects from the rstanarm package) into a summary.

Usage

"tidy"(x, parameters = c("non-varying", "varying", "hierarchical"), intervals = FALSE, prob = 0.9, ...)
"glance"(x, looic = FALSE, ...)

Arguments

x
Fitted model object from the rstanarm package. See stanreg-objects.
parameters
One of "non-varying", "varying", or "hierarchical" (can be abbreviated). See the Value section for details.
intervals
If TRUE columns for the lower and upper bounds of the 100*prob% posterior uncertainty intervals are included. See posterior_interval for details.
...
For glance, if looic=TRUE, optional arguments to loo.stanreg.
looic
Should the LOO Information Criterion be included? See loo.stanreg for details. Note: for models fit to very large data this can be a slow computation.

Value

All tidying methods return a data.frame without rownames. The structure depends on the method chosen.When parameters="non-varying" (the default), tidy.stanreg returns one row for each coefficient, with three columns:
term
The name of the corresponding term in the model.
estimate
A point estimate of the coefficient (posterior median).
std.error
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 parameters="varying" selects the group-level parameters instead of the non-varying regression coefficients. Addtional columns are added indicating the level and group. Specifying parameters="hierarchical" selects the standard deviations and (for certain models) correlations of the group-level parameters.If intervals=TRUE, columns for the lower and upper values of the posterior intervals computed with posterior_interval are also included.glance returns one row with the columns
algorithm
The algorithm used to fit the model.
pss
The posterior sample size (except for models fit using optimization).
nobs
The number of observations used to fit the model.
sigma
The square root of the estimated residual variance.
looic
If looic=TRUE, the LOO Information Criterion.

See Also

summary.stanreg

Examples

Run this code
if (require(rstanarm)) {
 fit <- stan_glmer(mpg ~ wt + (1|cyl) + (1+wt|gear), data = mtcars, 
                   iter = 500, chains = 2)
 tidy(fit, intervals = TRUE, prob = 0.5)
 tidy(fit, parameters = "hierarchical")
 tidy(fit, parameters = "varying")
 glance(fit, looic = TRUE, cores = 1)
}
 

Run the code above in your browser using DataCamp Workspace