R: Tidying methods for a brms model

brms_tidiers {broom} | R Documentation

## Tidying methods for a brms model

### Description

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

### Usage

    ## S3 method for class '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 `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.

### See Also

`brms`, `brmsfit-class`

### Examples

    ## 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)

    ## End(Not run)

[Package broom version 0.4.4 Index]