draws-brms | R Documentation |
brmsfit
to draws
objectsTransform a brmsfit
object to a format supported by the
posterior package.
## S3 method for class 'brmsfit'
as_draws(x, variable = NULL, regex = FALSE, inc_warmup = FALSE, ...)
## S3 method for class 'brmsfit'
as_draws_matrix(x, variable = NULL, regex = FALSE, inc_warmup = FALSE, ...)
## S3 method for class 'brmsfit'
as_draws_array(x, variable = NULL, regex = FALSE, inc_warmup = FALSE, ...)
## S3 method for class 'brmsfit'
as_draws_df(x, variable = NULL, regex = FALSE, inc_warmup = FALSE, ...)
## S3 method for class 'brmsfit'
as_draws_list(x, variable = NULL, regex = FALSE, inc_warmup = FALSE, ...)
## S3 method for class 'brmsfit'
as_draws_rvars(x, variable = NULL, regex = FALSE, inc_warmup = FALSE, ...)
x |
A |
variable |
A character vector providing the variables to extract. By default, all variables are extracted. |
regex |
Logical; Should variable should be treated as a (vector of)
regular expressions? Any variable in |
inc_warmup |
Should warmup draws be included? Defaults to |
... |
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.
draws
subset_draws
## Not run:
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)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.