EProportions · Guide test 075
Two sample exact Poisson rate test
Tests a rate ratio by conditioning on the combined event count.
Do it in CodeSplash
In the app, set it up in Analyze with this method:
- Poisson rates (one rate or two rates compared) — Is an event rate (events per unit of exposure) different from a reference value or between two groups?
In Poisson rates (one rate or two rates compared), choose Test (two rates) = Exact conditional test (rate ratio).
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 · Two sample exact Poisson rate test
Alternative
Your data
Edit the countsIf H₀ were true
- The reference: how x₁ varies across samples when H₀ is true.
- Your statistic, from the data above.
- The p-value: the total probability of outcomes no more likely than yours (p = .083).
- The hatched rejection region at α = .050: statistics landing here reject H₀.
The formula
With your numbers
- event counts
- exposures (person-time)
The verdict
x₁ = 24 of 41, p = .083, IRR = 1.76
p > α = .050: compatible with H₀
Effect size: rate ratio IRR = 1.765
Conditioning on the total turns the comparison into an exact binomial test — no large-sample approximation.
- Statistic
- 24.000
- p-value
- 0.0833
Two sample exact Poisson rate test on 24/800 vs 17/1000: x₁ = 24 of 41, p = .083, IRR = 1.76. The p-value is above α = .050, so the data are compatible with H₀.
Question and hypotheses
H0: λ1/λ2=r0, commonly r0=1.
Assumptions
Independent Poisson counts with known positive exposures.
Formula
Parameters and notation
t1,t2 are exposures and m the total event count; conditioning removes the common rate nuisance parameter.
Structure of the method
Condition independent Poisson counts on their sum, converting rate-ratio inference into an exact binomial allocation test. The binomial null probability depends on the target ratio and both exposures; this conditioning eliminates the unknown common rate scale.
Estimated and nuisance parameters
Observed rates and their ratio are descriptive estimates. The total event count determines the conditional information available; exposure durations are treated as fixed known quantities. The common rate magnitude is removed by conditioning instead of fitted inside the test statistic.
Settings and design choices
Prespecify the rate-ratio null, exposure units, alternative, two-sided ordering, and interval method. Unequal exposures must enter the null allocation probability; testing whether half the events belong to group one is appropriate only under matching exposure and ratio conditions.
Fitting and adaptation
Recompute the conditional allocation probability whenever exposures or the null ratio change. For a conditional calibration check, hold the total events fixed and simulate their allocation. This is distinct from the unconditional E-test and does not require neural-style fine-tuning or a reusable estimator.
Sensitivity and robustness
Very few total events lead to coarse p-values and wide or unbounded ratio intervals. Both groups having zero events provide no comparative rate information. Overdispersion or dependence within counts breaks the independent-Poisson conditioning argument even when the binomial calculation itself is exact.
How to use and calibrate
Apply the exact binomial test to the allocation of total events; report the rate ratio and interval.
Example application
Compare failures from machines observed for unequal operating times.
Interpretation and pitfalls
Watch out
This conditional exact method differs from the unconditional E test. Overdispersed counts need another sampling model.
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
Exact conditional comparison of two independent Poisson rates; r is the null rate ratio.
Not run — Executed end to end through Rscript · needs Python standard library + Rscript; R packages: base R
# 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(poisson.test(c(12,7),T=c(100,90),r=1))
"""
# 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()
Validated — Executed successfully in the validation environment · needs Base/standard library
print(poisson.test(c(12,7),T=c(100,90),r=1))
Output
Comparison of Poisson rates data: c(12, 7) time base: c(100, 90) count1 = 12, expected count1 = 10, p-value = 0.4918 alternative hypothesis: true rate ratio is not equal to 1 95 percent confidence interval: 0.5600386 4.6253411 sample estimates: rate ratio 1.542857
Sources
- R stats — R stats · poisson.teststat.ethz.ch
- poisson.teststat.ethz.ch
- Statistics guide v4 (historical):
- Python: Executed end to end through Rscript · R: Executed successfully in the validation 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 075, updated from the reference's edition 2 (reviewed 14 November 2026) as STAT075.