binbf01: Binomial Bayes factor

binbf01R Documentation

Binomial Bayes factor

Description

This function computes the Bayes factor for testing a binomial proportion p based on x observed successes out of n trials. Two types of tests are available:

  • Test of a point null hypothesis: The Bayes factor quantifies the evidence for H_0 \colon p = p_0 against H_1 \colon p \neq p_0. A beta prior is assigned to the proportion p under the alternative hypothesis H_1.

  • Test of a directional null hypothesis: The Bayes factor quantifies the evidence for H_0 \colon p \leq p_0 against H_1 \colon p > p_0. A beta prior that is truncated to the range [0, p_0] under the null H_0 and to (p_0, 1] under the alternative H_1 is assigned to the proportion p under the corresponding hypothesis.

Usage

binbf01(
  x,
  n,
  p0 = 0.5,
  type = c("point", "direction"),
  a = 1,
  b = 1,
  log = FALSE
)

Arguments

x

Number of successes

n

Number of trials

p0

Tested binomial proportion. Defaults to 0.5

type

Type of test. Can be "point" or "directional". Defaults to "point"

a

Number of successes parameter of the beta prior distribution. Defaults to 1

b

Number of failures parameter of the beta prior distribution. Defaults to 1

log

Logical indicating whether the natural logarithm of the Bayes factor should be returned. Defaults to FALSE

Value

Bayes factor in favor of the null hypothesis over the alternative (\text{BF}_{01} > 1 indicates evidence for the null hypothesis, whereas \text{BF}_{01} < 1 indicates evidence for the alternative)

Author(s)

Samuel Pawel

See Also

pbinbf01, nbinbf01

Examples

## example on Mendelian inheritance from ?stats::binom.test
binbf01(x = 682, n = 925, p0 = 3/4, a = 1, b = 1, type = "point")
## 18.6 => strong evidence for the hypothesized p = 3/4 compared to other p

## with directional hypothesis
binbf01(x = 682, n = 925, p0 = 3/4, a = 1, b = 1, type = "direction")
## 1.5 => only anecdotal evidence for p <= 3/4 over p > 3/4

## Particle-counting experiment from Stone (1997) with point null
binbf01(x = 106298, n = 527135, p0 = 0.2, a = 1, b = 1, type = "point")
## 8.1 => moderate evidence for the alternative over the null

## Coin flip experiment from Bartos et al. (2023) with point null
binbf01(x = 178079, n = 350757 , p0 = 0.5, a = 5100, b = 4900, type = "point")
## => 1/1.72e+17 extreme evidence in favor of the alternative over the null


bfpwr documentation built on June 8, 2025, 1:40 p.m.