pbinbf01: Cumulative distribution function of the binomial Bayes factor

pbinbf01R Documentation

Cumulative distribution function of the binomial Bayes factor

Description

This function computes the probability of obtaining a binomial Bayes factor (binbf01) more extreme than a threshold k with a specified sample size.

Usage

pbinbf01(
  k,
  n,
  p0 = 0.5,
  type = c("point", "direction"),
  a = 1,
  b = 1,
  dp = NA,
  da = a,
  db = b,
  dl = 0,
  du = 1,
  lower.tail = TRUE
)

Arguments

k

Bayes factor threshold

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 analysis prior distribution. Defaults to 1

b

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

dp

Fixed binomial proportion assumed for the power calculation. Set to NA to use a truncated beta design prior instead (specified via the da, db, dl, and du arguments). Defaults to NA

da

Number of successes parameter of the truncated beta design prior distribution. Is only taken into account if dp = NA. Defaults to the same value a as specified for the analysis prior

db

Number of failures parameter of the truncated beta design prior distribution. Is only taken into account if dp = NA. Defaults to the same value b as specified for the analysis prior

dl

Lower truncation limit of of the truncated beta design prior distribution. Is only taken into account if dp = NA. Defaults to 0

du

Upper truncation limit of of the truncated beta design prior distribution. Is only taken into account if dp = NA. Defaults to 1

lower.tail

Logical indicating whether Pr(\mathrm{BF}_{01} \leq k) (TRUE) or Pr(\mathrm{BF}_{01} > k) (FALSE) should be computed. Defaults to TRUE

Value

The probability that the Bayes factor is less or greater (depending on the specified lower.tail) than the specified threshold k

Author(s)

Samuel Pawel

See Also

binbf01, nbinbf01

Examples

## compute probability that BF > 10 under the point null
a <- 1
b <- 1
p0 <- 3/4
k <- 10
nseq <- seq(1, 1000, length.out = 100)
powH0 <- pbinbf01(k = k, n = nseq, p0 = p0, type = "point", a = a, b = b,
                  dp = p0, lower.tail = FALSE)
plot(nseq, powH0, type = "s", xlab = "n", ylab = "Power")

## compare to normal approximation
pm <- a/(a + b) # prior mean under H1
psd <- sqrt(a*b/(a + b)^2/(a + b + 1)) # prior standard deviation under H1
pownormH0 <- pbf01(k = k, n = nseq, usd = sqrt(p0*(1 - p0)), null = p0,
                   pm = pm, psd = psd, dpm = p0, dpsd = 0, lower.tail = FALSE)
lines(nseq, pownormH0, type = "s", col = 2)
legend("right", legend = c("Exact", "Normal approximation"), lty = 1,
       col = c(1, 2))

## compute probability that BF < 1/10 under the p|H1 ~ Beta(a, b) alternative
a <- 10
b <- 5
p0 <- 3/4
k <- 1/10
powH1 <- pbinbf01(k = k, n = nseq, p0 = p0, type = "point", a = a, b = b,
                  da = a, db = b, dl = 0, du = 1)
plot(nseq, powH1, type = "s", xlab = "n", ylab = "Power")

## compare to normal approximation
pm <- a/(a + b) # prior mean under H1
psd <- sqrt(a*b/(a + b)^2/(a + b + 1)) # prior standard deviation under H1
pownormH1 <- pbf01(k = k, n = nseq, usd = sqrt(pm*(1 - pm)), null = p0,
                   pm = pm, psd = psd, dpm = pm, dpsd = psd)
lines(nseq, pownormH1, type = "s", col = 2)
legend("right", legend = c("Exact", "Normal approximation"), lty = 1,
       col = c(1, 2))

## probability that directional BF <= 1/10 under uniform [3/4, 1] design prior
pow <- pbinbf01(k = 1/10, n = nseq, p0 = 3/4, type = "direction", a = 1, b = 1,
                da = 1, db = 1, dl = 3/4, du = 1)
plot(nseq, pow, type = "s", xlab = "n", ylab = "Power")

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