Version: | 1.1.0 |
Title: | Sequential Probability Ratio Test (SPRT) Method |
Description: | Provides functions to perform the Sequential Probability Ratio Test (SPRT) for hypothesis testing in Binomial, Poisson and Normal distributions. The package allows users to specify Type I and Type II error probabilities, decision thresholds, and compare null and alternative hypotheses sequentially as data accumulate. It includes visualization tools for plotting the likelihood ratio path and decision boundaries, making it easier to interpret results. The methods are based on Wald (1945) <doi:10.1214/aoms/1177731118>, who introduced the SPRT as one of the earliest and most powerful sequential analysis techniques. This package is useful in quality control, clinical trials, and other applications requiring early decision-making.The term 'SPRT' is an abbreviation and used intentionally. |
License: | MIT + file LICENSE |
Encoding: | UTF-8 |
RoxygenNote: | 7.3.2 |
Suggests: | knitr, rmarkdown |
VignetteBuilder: | knitr |
Imports: | stats, ggplot2, rlang |
NeedsCompilation: | no |
Packaged: | 2025-09-10 07:46:19 UTC; ADMIN |
Author: | Huchesh Budihal [aut, cre] |
Maintainer: | Huchesh Budihal <hhbudihal17@gmail.com> |
Repository: | CRAN |
Date/Publication: | 2025-09-15 07:50:09 UTC |
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
Plot SPRT results
Description
Plot SPRT results
Usage
sprt_plot(res)
Arguments
res |
A list returned by |
Value
A ggplot object showing the SPRT path with thresholds and decision point.
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)
sprt_plot(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_plot(result1)