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

  1. Put success and failure in rows, with groups in columns.
  2. Check every cell is a nonnegative integer and both group totals are positive.
  3. Prespecify the alternative and pooled versus unpooled statistic.
  4. Record the numerical sampling setting and software version.
  5. 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.

Related reading

Reading path: Analyze data. Guide 231 of 232. Choose any guide to suit your project.

Statistical Methods

Check Expected Counts Before a Contingency-Table Test

Audit category counts, independence, and sparse cells before interpreting a categorical association test.

Statistical Methods

Separate Boschloo\u2019s Test Statistic from Its Final P Value

Practical steps and a worked example: Read unconditional test output without misreporting its Fisher-based statistic.

Browse this reading pathTools for this stageGuides and downloads for this stage