Transform a brmsfit
object to a format supported by the
posterior package.
# S3 method for brmsfit
as_draws(x, variable = NULL, regex = FALSE, inc_warmup = FALSE, ...)
# S3 method for brmsfit
as_draws_matrix(x, variable = NULL, regex = FALSE, inc_warmup = FALSE, ...)
# S3 method for brmsfit
as_draws_array(x, variable = NULL, regex = FALSE, inc_warmup = FALSE, ...)
# S3 method for brmsfit
as_draws_df(x, variable = NULL, regex = FALSE, inc_warmup = FALSE, ...)
# S3 method for brmsfit
as_draws_list(x, variable = NULL, regex = FALSE, inc_warmup = FALSE, ...)
# S3 method for brmsfit
as_draws_rvars(x, variable = NULL, regex = FALSE, inc_warmup = FALSE, ...)
A brmsfit
object or another R object for which
the methods are defined.
A character vector providing the variables to extract. By default, all variables are extracted.
Logical; Should variable should be treated as a (vector of)
regular expressions? Any variable in x
matching at least one of the
regular expressions will be selected. Defaults to FALSE
.
Should warmup draws be included? Defaults to FALSE
.
Arguments passed to individual methods (if applicable).
To subset iterations, chains, or draws, use the
subset_draws
method after
transforming the brmsfit
to a draws
object.
if (FALSE) {
fit <- brm(count ~ zAge + zBase * Trt + (1|patient),
data = epilepsy, family = poisson())
# extract posterior draws in an array format
(draws_fit <- as_draws_array(fit))
posterior::summarize_draws(draws_fit)
# extract only certain variables
as_draws_array(fit, variable = "r_patient")
as_draws_array(fit, variable = "^b_", regex = TRUE)
# extract posterior draws in a random variables format
as_draws_rvars(fit)
}