sprt: Sequential Probability Ratio Test (SPRT)

View source: R/SPRT.R

sprtR Documentation

Sequential Probability Ratio Test (SPRT)

Description

Performs the SPRT for Bernoulli, Normal, or Poisson data.

Usage

sprt(
  x,
  alpha = 0.05,
  beta = 0.05,
  p0,
  p1,
  dist = c("bernoulli", "poisson", "normal"),
  sigma = 1
)

Arguments

x

Vector of observed values.

alpha

Type I error rate.

beta

Type II error rate.

p0

Null hypothesis parameter (probability or mean).

p1

Alternative hypothesis parameter (probability or mean).

dist

Distribution: "bernoulli", "normal", or "poisson".

sigma

Standard deviation (for normal distribution only).

Value

A list with elements:

decision

"Accept H0", "Reject H0", or "Continue sampling"

n_decision

Step at which decision was made (NA if continue)

logL

Cumulative log-likelihood ratios for each step

A

Upper threshold (log scale)

B

Lower threshold (log scale)

Examples

x <- c(0,0,1,0,1,1,1,0,0,1,0,0)
res <- sprt(x, alpha = 0.05, beta = 0.1, p0 = 0.1, p1 = 0.3)
print(res)
x1 <- c(52, 55, 58, 63, 66, 70, 74)
result1 <-sprt(x1, alpha = 0.05, beta = 0.1, p0 = 50, p1 = 65, dist = "normal", sigma = 10)
result1

SPRT documentation built on Sept. 15, 2025, 9:08 a.m.