The Sequential Probability Ratio Test (SPRT), proposed by Abraham Wald (1945), is a method of hypothesis testing that evaluates data sequentially rather than fixing the sample size in advance.
It is widely used in quality control, clinical trials, and agricultural research where early stopping can save both time and resources.
We test simple hypotheses:
[ H_0: \theta = \theta_0 \quad \text{vs.} \quad H_1: \theta = \theta_1 ]
After (n) observations ((X_1, X_2, \ldots, X_n)), the likelihood ratio is:
[ \Lambda_n = \prod_{i=1}^n \frac{f(X_i; \theta_1)}{f(X_i; \theta_0)} ]
or equivalently,
[ \log \Lambda_n = \sum_{i=1}^n \log \left( \frac{f(X_i; \theta_1)}{f(X_i; \theta_0)} \right). ]
To control Type I error ((\alpha)) and Type II error ((\beta)), Wald proposed comparing the likelihood ratio (\Lambda_n) with two thresholds.
where
[ A = \frac{1-\beta}{\alpha}, \qquad B = \frac{\beta}{1-\alpha}. ]
Type I error control: Probability of wrongly rejecting (H_0) should not exceed (\alpha).
This sets the upper boundary (A).
Type II error control: Probability of wrongly rejecting (H_1) should not exceed (\beta).
This sets the lower boundary (B).
Thus, the SPRT is designed so that:
[ P(\text{Reject } H_0 | H_0 \text{ true}) \leq \alpha, \qquad P(\text{Reject } H_1 | H_1 \text{ true}) \leq \beta. ]
This guarantees the desired error rates in the sequential framework.
Suppose we want to test whether the probability of success is (p_0 = 0.1) vs (p_1 = 0.3).
```r library(SPRT)
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)
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)
yield <- c(47, 50, 52, 49, 58, 61, 63, 54, 57)
fert_test <- sprt( yield, alpha = 0.05, beta = 0.1, p0 = 45, p1 = 55, dist = "normal", sigma = 8 )
fert_test sprt_plot(fert_test)
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.