broom (version 0.5.1)

brms_tidiers: Tidying methods for a brms model

Description

brms tidiers will soon be deprecated in broom and there is no ongoing development of these functions at this time. brms tidiers are being developed in the broom.mixed package, which is not yet on CRAN.

Usage

# S3 method for brmsfit
tidy(x, parameters = NA, par_type = c("all",
  "non-varying", "varying", "hierarchical"), robust = FALSE,
  intervals = TRUE, prob = 0.9, ...)

Arguments

x

Fitted model object from the brms package. See brms::brmsfit-class().

parameters

Names of parameters for which a summary should be returned, as given by a character vector or regular expressions. If NA (the default) summarized parameters are specified by the par_type argument.

par_type

One of "all", "non-varying", "varying", or "hierarchical" (can be abbreviated). See the Value section for details.

robust

Whether to use median and median absolute deviation rather than mean and standard deviation.

intervals

If TRUE columns for the lower and upper bounds of posterior uncertainty intervals are included.

prob

Defines the range of the posterior uncertainty intervals, such that 100 * prob% of the parameter's posterior distribution lies within the corresponding interval. Only used if intervals = TRUE.

...

Extra arguments, not used

Value

All tidying methods return a data.frame without rownames. The structure depends on the method chosen.

When parameters = NA, the par_type argument is used to determine which parameters to summarize.

Generally, tidy.brmsfit returns one row for each coefficient, with at least three columns:

term

The name of the model parameter.

estimate

A point estimate of the coefficient (mean or median).

std.error

A standard error for the point estimate (sd or mad).

When par_type = "non-varying", only population-level effects are returned.

When par_type = "varying", only group-level effects are returned. In this case, two additional columns are added:

group

The name of the grouping factor.

level

The name of the level of the grouping factor.

Specifying par_type = "hierarchical" selects the standard deviations and correlations of the group-level parameters.

If intervals = TRUE, columns for the lower and upper bounds of the posterior intervals computed.

Details

These methods tidy the estimates from brms::brmsfit() (fitted model objects from the brms package) into a summary.

See Also

brms::brms(), brms::brmsfit()

Examples

Run this code
# NOT RUN {
 library(brms)
 fit <- brm(mpg ~ wt + (1|cyl) + (1+wt|gear), data = mtcars,
            iter = 500, chains = 2)
 tidy(fit)
 tidy(fit, parameters = "^sd_", intervals = FALSE)
 tidy(fit, par_type = "non-varying")
 tidy(fit, par_type = "varying")
 tidy(fit, par_type = "hierarchical", robust = TRUE)
# }
# NOT RUN {
# }

Run the code above in your browser using DataCamp Workspace