prior_draws.brmsfit {brms} | R Documentation |
Extract Prior Draws
Description
Extract prior draws of specified parameters
Usage
## S3 method for class 'brmsfit'
prior_draws(x, variable = NULL, pars = NULL, ...)
prior_draws(x, ...)
prior_samples(x, ...)
Arguments
x |
An |
variable |
A character vector providing the variables to extract. By default, all variables are extracted. |
pars |
Deprecated alias of |
... |
Arguments passed to individual methods (if applicable). |
Details
To make use of this function, the model must contain draws of
prior distributions. This can be ensured by setting sample_prior =
TRUE
in function brm
. Priors of certain parameters cannot be saved
for technical reasons. For instance, this is the case for the
population-level intercept, which is only computed after fitting the model
by default. If you want to treat the intercept as part of all the other
regression coefficients, so that sampling from its prior becomes possible,
use ... ~ 0 + Intercept + ...
in the formulas.
Value
A data.frame
containing the prior draws.
Examples
## Not run:
fit <- brm(rating ~ treat + period + carry + (1|subject),
data = inhaler, family = "cumulative",
prior = set_prior("normal(0,2)", class = "b"),
sample_prior = TRUE)
# extract all prior draws
draws1 <- prior_draws(fit)
head(draws1)
# extract prior draws for the coefficient of 'treat'
draws2 <- prior_draws(fit, "b_treat")
head(draws2)
## End(Not run)