# bf: Bayes Factor(s) from Marginal Likelihoods In bridgesampling: Bridge Sampling for Marginal Likelihoods and Bayes Factors

## Description

Generic function that computes Bayes factor(s) from marginal likelihoods. `bayes_factor()` is simply an (S3 generic) alias for `bf()`.

## Usage

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15``` ```bf(x1, x2, log = FALSE, ...) bayes_factor(x1, x2, log = FALSE, ...) ## Default S3 method: bayes_factor(x1, x2, log = FALSE, ...) ## S3 method for class 'bridge' bf(x1, x2, log = FALSE, ...) ## S3 method for class 'bridge_list' bf(x1, x2, log = FALSE, ...) ## Default S3 method: bf(x1, x2, log = FALSE, ...) ```

## Arguments

 `x1` Object of class `"bridge"` or `"bridge_list"` as returned from `bridge_sampler`. Additionally, the default method assumes that `x1` is a single numeric log marginal likelihood (e.g., from `logml`) and will throw an error otherwise. `x2` Object of class `"bridge"` or `"bridge_list"` as returned from `bridge_sampler`. Additionally, the default method assumes that `x2` is a single numeric log marginal likelihood (e.g., from `logml`) and will throw an error otherwise. `log` Boolean. If `TRUE`, the function returns the log of the Bayes factor. Default is `FALSE`. `...` currently not used here, but can be used by other methods.

## Details

Computes the Bayes factor (Kass & Raftery, 1995) in favor of the model associated with `x1` over the model associated with `x2`.

## Value

For the default method returns a list of class `"bf_default"` with components:

• `bf`: (scalar) value of the Bayes factor in favor of the model associated with `x1` over the model associated with `x2`.

• `log`: Boolean which indicates whether `bf` corresponds to the log Bayes factor.

For the method for `"bridge"` objects returns a list of class `"bf_bridge"` with components:

• `bf`: (scalar) value of the Bayes factor in favor of the model associated with `x1` over the model associated with `x2`.

• `log`: Boolean which indicates whether `bf` corresponds to the log Bayes factor.

For the method for `"bridge_list"` objects returns a list of class `"bf_bridge_list"` with components:

• `bf`: a numeric vector consisting of Bayes factors where each element gives the Bayes factor for one set of logmls in favor of the model associated with `x1` over the model associated with `x2`. The length of this vector is given by the `"bridge_list"` element with the most `repetitions`. Elements with fewer repetitions will be recycled (with warning).

• `bf_median_based`: (scalar) value of the Bayes factor in favor of the model associated with `x1` over the model associated with `x2` that is based on the median values of the logml estimates.

• `log`: Boolean which indicates whether `bf` corresponds to the log Bayes factor.

## Note

For examples, see `bridge_sampler` and the accompanying vignettes:
`vignette("bridgesampling_example_jags")`
`vignette("bridgesampling_example_stan")`

## Author(s)

Quentin F. Gronau

## References

Kass, R. E., & Raftery, A. E. (1995). Bayes factors. Journal of the American Statistical Association, 90(430), 773-795. doi: 10.1080/01621459.1995.10476572

bridgesampling documentation built on April 16, 2021, 9:07 a.m.