| 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. |
| Authors: | Huchesh Budihal [aut, cre] |
| Maintainer: | Huchesh Budihal <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 1.1.0 |
| Built: | 2026-05-17 07:16:19 UTC |
| Source: | https://github.com/cran/SPRT |
Performs the SPRT for Bernoulli, Normal, or Poisson data.
sprt( x, alpha = 0.05, beta = 0.05, p0, p1, dist = c("bernoulli", "poisson", "normal"), sigma = 1 )sprt( x, alpha = 0.05, beta = 0.05, p0, p1, dist = c("bernoulli", "poisson", "normal"), sigma = 1 )
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). |
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) |
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) result1x <- 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
sprt_plot(res)sprt_plot(res)
res |
A list returned by |
A ggplot object showing the SPRT path with thresholds and decision point.
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)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)