Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

prior_samples.brmsfit

Extract prior samples


Description

Extract prior samples of specified parameters

Usage

## S3 method for class 'brmsfit'
prior_samples(x, pars = NA, ...)

prior_samples(x, pars = NA, ...)

Arguments

x

An R object typically of class brmsfit

pars

Names of parameters for which prior samples should be returned, as given by a character vector or regular expressions. By default, all prior samples are extracted

...

Currently ignored

Details

To make use of this function, the model must contain samples 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 samples.

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 samples
samples1 <- prior_samples(fit)
head(samples1)

# extract prior samples for the population-level effects of 'treat'
samples2 <- prior_samples(fit, "b_treat")
head(samples2)

## End(Not run)

brms

Bayesian Regression Models using 'Stan'

v2.15.0
GPL-2
Authors
Paul-Christian Bürkner [aut, cre], Jonah Gabry [ctb], Sebastian Weber [ctb], Andrew Johnson [ctb], Martin Modrak [ctb]
Initial release
2021-03-10

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.