Shiny App for an SPRT
Build an interactive R Shiny app that implements a Sequential Probability Ratio Test (SPRT) to decide whether the average life expectancy for patients with a specific disease equals to 5 years or 6 years. Assume life expectancy follows an exponential distribution. Your app should:
Allow users to input simulated patient survival times.
Sequentially apply SPRT and display whether to accept \(H_0\), accept \(H_1\), or continue sampling.
Setup
We frame a one-sided test using simple hypotheses required by SPRT:
\[ H_0:\frac{1}{\lambda} = 5 \]
\[ H_1: \frac{1}{\lambda} = 6 \] Under the assumption, survival time follow exponential distribution with the following pdf: \[ f(x) = \lambda e^{-\lambda x}, x>0 \] Now derive the likelihood ratio statistic:
\[ \Lambda_n = \frac{L_{1,n}}{L_{0,n}} = ? \] with the boundary: \[ A = ? \ \ \ \ \text{ , } \ \ \ \ \ \ \ \ \ B = ? \] Now clearly state your stopping rule, and change the corresponding codes in the template and test on a few observations.