Statistical Methods
Orient a Two-by-Two Table Before Barnard\u2019s Test
Define the research task
Barnard’s unconditional exact test is an option for two independent binomial groups. Table orientation matters: SciPy treats columns as the two samples. Its statistic and final p value are different outputs. A table assembled from matched pairs or clustered observations does not meet the same independence design.
Work through the check
- Put success and failure in rows, with groups in columns.
- Check every cell is a nonnegative integer and both group totals are positive.
- Prespecify the alternative and pooled versus unpooled statistic.
- Record the numerical sampling setting and software version.
- If numerical sensitivity matters, repeat with a larger sampling setting and retain both results.
The final p value accounts for a nuisance probability under the null; it is not simply a normal-tail probability for the displayed statistic. Do not report the statistic as an effect estimate.
Hypothetical example and reporting
A hypothetical table [[3,1],[2,4]] represents success rates 3/5 and 1/5, a risk difference of 0.4. The pooled proportion is 0.4; the pooled Wald denominator is sqrt(0.4×0.6×(1/5+1/5)), approximately 0.309839. The resulting statistic is about 1.290994. This arithmetic checks orientation, not the unconditional p value. Report absolute group risks alongside inference.
Source and verification
Method checked 26 November 2026 against SciPy primary documentation: stats.barnard_exact. Examples are synthetic; this page does not assert human expert approval.