Learn R Programming

brms (version 1.10.2)

bridge_sampler.brmsfit: Log Marginal Likelihood via Bridge Sampling

Description

Computes log marginal likelihood via bridge sampling, which can be used in the computation of bayes factors and posterior model probabilities. The brmsfit method is just a thin wrapper around the corresponding method for stanfit objects.

Usage

# S3 method for brmsfit
bridge_sampler(samples, ...)

Arguments

samples

A brmsfit object.

...

Additional arguments passed to bridge_sampler.stanfit.

Details

Computing the marginal likelihood requires samples of all variables defined in Stan's parameters block to be saved. Otherwise bridge_sampler cannot be computed. Thus, please set save_all_pars = TRUE in the call to brm, if you are planning to apply bridge_sampler to your models.

More details are provided under bridge_sampler.

See Also

bayes_factor, post_prob

Examples

Run this code
# NOT RUN {
# model with the treatment effect
fit1 <- brm(
  count ~ log_Age_c + log_Base4_c + Trt_c,
  data = epilepsy, family = negbinomial(), 
  prior = prior(normal(0, 1), class = b),
  save_all_pars = TRUE
)
summary(fit1)
bridge_sampler(fit1)

# model without the treatment effect
fit2 <- brm(
  count ~ log_Age_c + log_Base4_c,
  data = epilepsy, family = negbinomial(), 
  prior = prior(normal(0, 1), class = b),
  save_all_pars = TRUE
)
summary(fit2)
bridge_sampler(fit2)
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab