BCompare groups · Guide test 291
Conditional MaxSPRT
Conditions on historical event information in sequential event rate surveillance.
Do it in CodeSplash
In the app, set it up in Analyze with this method:
- Sequential probability ratio tests — Wald SPRT, MaxSPRT and conditional MaxSPRT — Can I decide after every observation (or event) while keeping the planned error rates?
In Sequential probability ratio tests — Wald SPRT, MaxSPRT and conditional MaxSPRT, choose Test = Conditional MaxSPRT (baseline from historical data).
Do it in CodeSplash Run this test on your own data, in Python or R.
Bench
Change the design, drag the data, move α. The statistic, its reference distribution and the verdict follow.
Bench · Conditional MaxSPRT
Your data
Current events against a historical countThe log-LR compares current events with the historical rate, with the uncertainty of the historical count built in.
If H₀ were true
- The reference: how LLR varies across samples when H₀ is true, the largest conditional log-LR under H₀ (exact) (sequential p: the exact α of a design whose critical value equals your largest log-LR).
- Your statistic, from the data above.
- The p-value: the area at least as extreme as yours (p = .233).
- The hatched rejection region at α = .050: statistics landing here reject H₀.
The formula
With your numbers
- historical events and person-time
- current events and person-time; u = P/V
- exact critical value for stopping at the K-th current event (Li & Kulldorff 2010)
The verdict
LLR = 1.30, p = .233
p > α = .050: compatible with H₀
Conditions on the historical count, so a small historical sample widens what counts as surprising. Its p is the smallest α at which this path would have signaled.
- Statistic
- 1.305
- p-value
- 0.2327
Conditional MaxSPRT on 20 current events against 20 historical ones: LLR = 1.30, p = .233. The p-value is above α = .050, so the data are compatible with H₀.
Question and hypotheses
H0: current and historical Poisson rates are equal; H1: current rate is higher.
Assumptions
Independent historical and surveillance Poisson processes; specified historical conditioning scheme and sequential horizon.
Formula
Parameters and notation
Historical count c over exposure V; current count x over exposure P. Set LLR=0 if the estimated relative risk xV/(cP)≤1. Zero terms use continuous limits.
Structure of the method
Compare current and historical Poisson rates while conditioning according to the specified historical/surveillance scheme, and monitor a maximized likelihood ratio over time. Historical uncertainty changes the sequential boundary relative to a MaxSPRT that treats the baseline expectation as known.
Estimated and nuisance parameters
Historical count/exposure and current count/exposure determine rate estimates and the constrained common-rate likelihood. The relative risk is estimated under the elevated-risk alternative, while the baseline is a nuisance quantity handled by conditioning. Conditioning design is not an estimated parameter.
Settings and design choices
Choose whether surveillance ends by current cases or person-time ratio, historical event count, minimum events and exact/liberal/conservative boundary calculation. The example uses StopType="Cases", K=20 and cc=20. Distinguish fixed historical exposure from sampling until a historical event count, because calibration depends on the scheme.
Fitting and adaptation
Use the package’s compatible setup and analysis workflow, passing event and exposure increments as required. Recalibration is needed if the design changes. This is sequential likelihood fitting, not neural fine-tuning; a running maximum likelihood estimate must be paired with the correct conditional crossing distribution.
Sensitivity and robustness
Limited historical events increase uncertainty, while temporal trends and different population composition violate comparability. Historical and current processes must satisfy the assumed relationship. Zero-count terms require continuous limits, and an estimated relative risk at or below one gives zero one-sided evidence rather than a negative log likelihood ratio.
How to use and calibrate
Use conditional MaxSPRT boundaries calibrated for historical uncertainty, conditioning scheme, horizon and look schedule.
Example application
Monitor an event rate when baseline risk is estimated from a historical comparator.
Interpretation and pitfalls
Watch out
Treating an estimated historical rate as known understates uncertainty. Fixed-count historical sampling and fixed-exposure sampling must match the implementation.
What changed in edition 2
- New sections: structure of the method, estimated and nuisance parameters, settings and design choices, fitting and adaptation, sensitivity and robustness.
Python and R
Conditional MaxSPRT design with 20 historical events and a surveillance cap of 20 cases; computes a boundary for this exact monitoring plan, not a generic fixed-sample cutoff.
Not run — Python launcher syntax checked; R backend runtime not verified · needs Python standard library + Rscript; R packages: Sequential
# Python launcher for the complete R implementation below.
# Requires Rscript on PATH and the listed R packages.
import shutil
import subprocess
rscript = shutil.which("Rscript")
if rscript is None:
raise RuntimeError("Install R and make Rscript available on PATH.")
r_code = r"""
print(Sequential::CV.CondPoisson(Inference="exact",StopType="Cases",K=20,cc=20,M=2,alpha=.05))
"""
# No shell interpolation. A failed R execution raises an error in Python.
result = subprocess.run([rscript, "--vanilla", "-"], input=r_code,
text=True, capture_output=True)
print(result.stdout)
if result.stderr:
print(result.stderr)
result.check_returncode()
Not run — Syntax checked; runtime not verified in the final environment · needs Sequential
print(Sequential::CV.CondPoisson(Inference="exact",StopType="Cases",K=20,cc=20,M=2,alpha=.05))
Sources
- Sequential — Sequential · CV.CondPoissonAuthor documentation/source reviewed: Sequential 4.6.3.search.r-project.org
- Sequential — Sequential · Analyze.CondPoissonAuthor documentation/source reviewed: Sequential 4.6.3.search.r-project.org
- CV.CondPoissonsearch.r-project.org
- Analyze.CondPoissonsearch.r-project.org
- Statistics guide v4 (historical):
- Python: Python launcher syntax checked; R backend runtime not verified · R: Syntax checked; runtime not verified in the final environment
- Reference's record:
- Edition 2 review: Python: skip · R: not executed (Rscript unavailable); why not run: Python: Python-to-R bridge; Rscript is unavailable. R code was not executed. Python: Not run in the reference's review: Python-to-R bridge; Rscript is unavailable. R code was not executed. R: Reviewed but not run: R wasn't available to the reference's authors.
From the CodeSplash statistics guide (v4), entry 291, updated from the reference's edition 2 (reviewed 14 November 2026) as STAT291.