powerbinbf01: Power and sample size calculations for binomial Bayes factor

View source: R/powerbinbf01.R

powerbinbf01R Documentation

Power and sample size calculations for binomial Bayes factor

Description

Compute probability that binomial Bayes factor (binbf01) is smaller than a specified threshold (the power), or determine sample size to obtain a target power.

Usage

powerbinbf01(
  n = NULL,
  power = NULL,
  k = 1/10,
  p0 = 0.5,
  type = c("point", "direction"),
  a = 1,
  b = 1,
  dp = NA,
  da = a,
  db = b,
  dl = 0,
  du = 1,
  nrange = c(1, 10^4)
)

Arguments

n

Sample size. Has to be NULL if power is specified. Defaults to NULL

power

Target power. Has to be NULL if n is specified. Defaults to NULL

k

Bayes factor threshold. Defaults to 1/10, Jeffreys' threshold for 'strong evidence' against the null hypothesis

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

nrange

Sample size search range over which numerical search is performed (only taken into account when n is NULL). Defaults to c(1, 10^3)

Details

This function provides a similar interface as stats::power.prop.test. For some users, the low-level functions nbinbf01 (to directly compute the sample size for a fixed power) and pbinbf01 (to directly compute the power for a fixed sample size) may also be useful.

Value

Object of class "power.bftest", a list of the arguments (including the computed one) augmented with method and note elements

Author(s)

Samuel Pawel

See Also

plot.power.bftest, pbinbf01, nbinbf01, binbf01

Examples

## determine sample size
(nres <- powerbinbf01(power = 0.8, p0 = 0.2, type = "direction", dl = 0.2))
## Not run: 
plot(nres, nlim = c(1, 250), ngrid = 250, type = "s")

## End(Not run)

## determine power
(powres <- powerbinbf01(n = 100, type = "point"))
## Not run: 
plot(powres)

## End(Not run)


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