Generic function that computes Bayes factor(s) from marginal likelihoods. bayes_factor() is simply an (S3 generic) alias for bf().
Usage
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 frombridge_sampler. Additionally, the default method assumes thatx1is a single numeric log marginal likelihood (e.g., fromlogml) and will throw an error otherwise.- x2
Object of class
"bridge"or"bridge_list"as returned frombridge_sampler. Additionally, the default method assumes thatx2is a single numeric log marginal likelihood (e.g., fromlogml) and will throw an error otherwise.- log
Boolean. If
TRUE, the function returns the log of the Bayes factor. Default isFALSE.- ...
currently not used here, but can be used by other methods.
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 withx1over the model associated withx2.log: Boolean which indicates whetherbfcorresponds 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 withx1over the model associated withx2.log: Boolean which indicates whetherbfcorresponds 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 withx1over the model associated withx2. The length of this vector is given by the"bridge_list"element with the mostrepetitions. Elements with fewer repetitions will be recycled (with warning).bf_median_based: (scalar) value of the Bayes factor in favor of the model associated withx1over the model associated withx2that is based on the median values of the logml estimates.log: Boolean which indicates whetherbfcorresponds to the log Bayes factor.
Details
Computes the Bayes factor (Kass & Raftery, 1995) in favor of the model associated with x1 over the model associated with x2.
Note
For examples, see bridge_sampler and the accompanying vignettes: vignette("bridgesampling_example_jags") vignette("bridgesampling_example_stan")
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