prior_draws.brmsfit: Extract Prior Draws

View source: R/prior_draws.R

prior_draws.brmsfitR Documentation

Extract Prior Draws


Extract prior draws of specified parameters


## S3 method for class 'brmsfit'
prior_draws(x, variable = NULL, pars = NULL, ...)

prior_draws(x, ...)

prior_samples(x, ...)



An R object typically of class brmsfit.


A character vector providing the variables to extract. By default, all variables are extracted.


Deprecated alias of variable. For reasons of backwards compatibility, pars is interpreted as a vector of regular expressions by default unless fixed = TRUE is specified.


Arguments passed to individual methods (if applicable).


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.


A data.frame containing the prior draws.


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

# extract prior draws for the coefficient of 'treat'
draws2 <- prior_draws(fit, "b_treat")

## End(Not run)

brms documentation built on Sept. 19, 2022, 5:06 p.m.