prior_draws.brmsfit: Extract Prior Draws

Description Usage Arguments Details Value Examples

View source: R/prior_draws.R

Description

Extract prior draws of specified parameters

Usage

1
2
3
4
5
6
## S3 method for class 'brmsfit'
prior_draws(x, variable = NULL, pars = NULL, ...)

prior_draws(x, ...)

prior_samples(x, ...)

Arguments

x

An R object typically of class brmsfit.

variable

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

pars

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

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
## 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)

brms documentation built on Aug. 23, 2021, 5:08 p.m.