Bridge Sampling for Marginal Likelihoods and Bayes Factors

Provides functions for estimating marginal likelihoods, Bayes factors, posterior model probabilities, and normalizing constants in general, via different versions of bridge sampling (Meng & Wong, 1996, <>). Gronau, Singmann, & Wagenmakers (2020) .


                   ** bridgesampling VERSION 0.6-x **

                Changes in bridgesampling Version 0.6-x
                Released October 2018

Significant User Visible Changes and New Features

o Added nimble vignette (Hierarchical Normal Example)

o Added accepted JSS version of introductory paper, but kept existing version as extended version.


o R CMD check on the package tar.gz should now run without packages that are
in suggests installed (if the corresponding environment variable is set). Also, all vignettes should compile without suggested packages (achieved by precalculating the results and then loading them).

                   ** bridgesampling VERSION 0.5-x **

                Changes in bridgesampling Version 0.5-x
                Released August 2018

Significant User Visible Changes and New Features

o Added support for nimble objects ( via bridge_sampler.MCMC_refClass method. Thanks to Perry de Valpine for his help in creating this method.

o The print methods for the bf() function now try to deparse the model names from the user input and use these names instead of x1 and x2.

o Added support for simplex and circular parameters which can be specified using the new argument param_types of the bridge_sampler function (thanks to Kees Mulder)



                   ** bridgesampling VERSION 0.4-x **

                Changes in bridgesampling Version 0.4-x
                Released December 2017

Significant User Visible Changes and New Features

o More informative error messages for methods due to checking of input values: - bridge_sampler() methods now check lb and ub. - bf() methods check class of x2. - post_prob() checks if only one object of appropriate class is passed.

o Promoted error_measures() to generic function with methods for both repetitions = 1 and repetitions > 1. In the latter case median and IQR are reported. The only situation where we can not report error measures is if repetitions = 1 and method = "warp3".

o Added summary() (and corresponding print.summary) methods for bridge and bridge_list objects. These methods now always invoke error_measures() and return a data.frame with both log marginal likelihood and error information. These methods are described in ?bridge-methods.

o Updated bridgesampling vignette to latest version.


o Retroactively updated the NEWS file.

                   ** bridgesampling VERSION 0.3-x **

                Changes in bridgesampling Version 0.3-x
                Released October 2017

Significant User Visible Changes and New Features

o Added a variety of new methods for bridge_sampler() that automatically extract the posterior samples, but also require a log_posterior function. Specifically, bridge_sampler() now has methods of this kind for the following objects: matrix, mcmc.list, rjags, and runjags.

o Added stanreg method to bridge_sampler() which allows to pass objects from rstanarm. Note that this method requires to specify the diagnostic_file option, see examples. Thanks to Ben Goodrich for the pull request.

o Added new vignette introducing the package: bridgesampling: An R Package for Estimating Normalizing Constants

o Added two new data sets plus code used in the new vignette, see ?ier and ?turtles

o Added bayes_factor() as alias for bf(), as bf() is an existing function in package brms.

o Added use_neff argument to bridge_sampler() which allows to determine whether the effective sample size or the actual sample size is used for bridge sampling.


o bridge_sampler() for stan objects on windows should not fail anymore if cores > 1. Instead, cores will be set to 1 (with warnings).

                   ** bridgesampling VERSION 0.2-x **

                Changes in bridgesampling Version 0.2-x
                Released June 2017

Significant User Visible Changes and New Features

o Added stan_bridge_sampler(), which allows one to obtain the marginal likelihood directly from a fitted stanfit object that contains posterior samples. Note that it may be necessary to compile a new stanfit object without samples if the one with samples was compiled in a different session/pc. See new vignettes for examples.

o Added repetitions argument to bridge sampler functions which allows to compute independent bridge sample estimates (based on the same posterior samples). bridge_sampler() now returns object of class "bridge" for calculations with repetitions = 1, but an object of class "bridge_list" if repetitions > 1, the latter contains the full list of estimates (but no q vectors).

o Renamed compute_post_prob() to post_prob(), which is now a generic function with methods for bridge objects. The default method allows just logml values. For "bridge_list" objects (i.e., with repetitions > 1) a matrix of posterior probabilities with rows for each repetition is returned.

o added new generic function logml() which returns the log marginal likelihood as a scalar value.

o Multicore computations (i.e., cors > 1) on Unix-like systen (e.g., Mac OS, Linux) are now performed with forking via parallel::mcapply().


o compute_post_prob() now works even when exp(logml) initially returns Inf (solution works via brobdingnag).

o Bridge sampler more robust due to various small improvements and produces more informative error messages should it fail.

o If log_prob() returns NA, these values are replaced with -Inf on the log scale (which assumes a likelihood of 0). With warning.

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.


1.1-2 by Quentin F. Gronau, 6 months ago

Browse source code at

Authors: Quentin F. Gronau [aut, cre] , Henrik Singmann [aut] , Jonathan J. Forster [ctb] , Eric-Jan Wagenmakers [ths] , The JASP Team [ctb] , Jiqiang Guo [ctb] , Jonah Gabry [ctb] , Ben Goodrich [ctb] , Kees Mulder [ctb] , Perry de Valpine [ctb]

Documentation:   PDF Manual  

Task views: Bayesian Inference

GPL (>= 2) license

Imports mvtnorm, Matrix, Brobdingnag, stringr, coda, parallel, scales, utils, methods

Suggests testthat, Rcpp, RcppEigen, R2jags, rjags, runjags, knitr, rmarkdown, R.rsp, BayesFactor, rstan, rstanarm, nimble, MCMCpack

Imported by BAMBI, BayesTools, BayesianFROC, BayesianTools, RoBMA, StanMoMo, bayesforecast, brms, metaBMA.

Suggested by bayestestR, bmscstan.

See at CRAN