bfbinom: Bayesian Sequential Binomial Test

View source: R/bayestest.R

bfbinomR Documentation

Bayesian Sequential Binomial Test

Description

Calculates Bayes Factors sequentially for dichotomous data, showing evidence evolution over time. Uses 'proportionBF' from the BayesFactor package to compute Bayes Factors starting from a minimum number of observations and updating with each new data point.

Usage

bfbinom(
  data,
  p = 0.5,
  prior.r = 0.1,
  alternative = c("two.sided", "greater", "less"),
  nstart = 5,
  exact = TRUE,
  nullInterval = NULL
)

Arguments

data

A vector containing binary data (0s and 1s)

p

Probability of success under the null hypothesis (default: 0.5)

prior.r

Scale parameter for the prior distribution (default: 0.1)

alternative

Direction of alternative hypothesis: "two.sided", "greater", or "less"

nstart

Minimum number of data points before first BF calculation (>= 2)

exact

Logical. If TRUE, calculates BF for all points; if FALSE, uses steps for efficiency

nullInterval

Optional vector of length 2 for interval hypothesis testing (deprecated)

Value

A list of class "seqbf" containing:

  • probability of success: estimated probability

  • p-value: from classical binomial test

  • BF: vector of sequential Bayes Factors

  • test type: "binomial"

  • prior: list with prior distribution details

  • sample size: total number of observations

  • alternative: chosen alternative hypothesis

Examples

data <- rbinom(100, 1, 0.7)
result <- bfbinom(data)

mrzdcmps/changeofevidence documentation built on Feb. 27, 2025, 3:10 a.m.