EProportions · Guide test 063
Boschloo exact test
Uses the Fisher p value as a statistic in an unconditional test of two binomial proportions.
Do it in CodeSplash
In the app, set it up in Analyze with this method:
- Two independent proportions (z, Fisher, Boschloo, Barnard, non-inferiority) — Does the share of an outcome differ between two independent groups?
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 · Boschloo exact test
Alternative
Your data
Edit the counts| Success | Failure | Total | |
|---|---|---|---|
| Row 1 | 9E = 5.5 | 3E = 6.5 | 12 |
| Row 2 | 2E = 5.5 | 10E = 6.5 | 12 |
| Total | 11 | 13 | 24 |
E is the count expected if rows and columns were unrelated.
If H₀ were true
Shaded: the 21 outcomes whose Fisher p is no larger than yours (the outlined cell is your table). Only the group sizes are fixed, so the probability of that region depends on the unknown common proportion π; the test takes its largest value over π, which can never be smaller than the p at the true π.
The formula
With your numbers
- Fisher's one-sided p-value, used as the ordering statistic
- the common proportion, maximized over
The verdict
p_F = 0.0061, p = .007
p ≤ α = .050: reject H₀
Always at least as powerful as Fisher's test: it orders tables the same way but drops the conditioning on the column total. Two-sided p doubles the smaller one-sided p.
- Statistic
- 0.006
- p-value
- 0.0066
Boschloo exact test on a 2 × 2 table of 24 counts: p_F = 0.0061, p = .007. The p-value is below α = .050, so the data are hard to reconcile with H₀.
Question and hypotheses
H0: two independent binomial probabilities are equal.
Assumptions
Independent binomial samples with fixed sample sizes.
Formula
Parameters and notation
pF is a chosen Fisher exact p value used as the ordering statistic; pB is the unconditional maximized probability.
Structure of the method
Use a Fisher conditional p-value to order independent-binomial outcomes, then maximize the unconditional probability of the resulting rejection region over the common null success probability. The final p-value is therefore different from the Fisher value used as an ordering statistic.
Estimated and nuisance parameters
Observed proportions summarize the groups; the common success probability is a nuisance over which the calculation maximizes. The Fisher statistic depends on each hypothetical table and its margins. Fixed sample sizes define the unconditional outcome space, while total successes are allowed to vary.
Settings and design choices
State the one-sided ordering and how a two-sided result is formed. SciPy doubles the smaller one-sided unconditional p-value and clips at one; other implementations can use different conventions. Set numerical precision and confirm the same convention before comparing Python and R outputs.
Fitting and adaptation
Each new table requires a fresh unconditional enumeration and nuisance maximization. Sensitivity checks can vary the numerical grid or optimizer settings while preserving the statistical ordering. Fine-tuning does not apply; selecting the most favorable two-sided convention after inspection changes the procedure.
Sensitivity and robustness
Discreteness, small event counts, and numerical optimization can affect reported values. Uniform power comparisons require the same conditional ordering and alternatives; do not generalize them to every two-sided variant. As with Barnard, clustered binary data violate the simple independent-binomial experiment.
How to use and calibrate
Enumerate binomial tables, order them by Fisher p values, and maximize the rejection probability over p0.
Example application
Obtain an unconditional exact comparison of two small response rates.
Interpretation and pitfalls
Watch out
Different two sided conventions yield different implementations. The Fisher p value is the statistic here, not the final Boschloo p value.
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
Rows are groups and columns success/failure; SciPy unconditional tests take the two binomial samples in columns, hence transpose.
Validated — Executed successfully in the validation environment · needs numpy, scipy
import numpy as np
from scipy import stats
rng = np.random.default_rng(2026)
tab = np.array([[18,12],[9,21]])
print(stats.boschloo_exact(tab.T))
Output
BoschlooExactResult(statistic=np.float64(0.018496197970255555), pvalue=np.float64(0.022665132902088648))
Validated — Executed successfully in the validation environment · needs exact2x2
tab <- matrix(c(18,12,9,21),nrow=2,byrow=TRUE)
print(exact2x2::boschloo(x1=18,n1=30,x2=9,n2=30,alternative="two.sided"))
Output
Boschloo's test
data: x1/n1=(18/30) and x2/n2= (9/30)
proportion 1 = 0.6, proportion 2 = 0.3, p-value = 0.02266
alternative hypothesis: true p2(1-p1)/[p1(1-p2)] is less than 1
percent confidence interval:
NA NA
sample estimates:
p2(1-p1)/[p1(1-p2)]
0.2857143Sources
- SciPy — SciPy · boschloo_exactdocs.scipy.org
- scipy.stats.boschloo_exactdocs.scipy.org
- boschloosearch.r-project.org
- Statistics guide v4 (historical):
- R: Executed successfully in the validation environment
- Reference's record:
- Edition 2 review: Python: executed · R: not executed (Rscript unavailable). Python: Ran in the reference's review, on this exact code. R: Reviewed but not run: R wasn't available to the reference's authors.
From the CodeSplash statistics guide (v4), entry 063, updated from the reference's edition 2 (reviewed 14 November 2026) as STAT063.