- Introduced by
- George A. Barnard
- Year
- 1945
- Type
- Unconditional exact test for 2×2 contingency tables
What does it do?
Barnard's exact test is an unconditional exact hypothesis test for comparing two independent proportions in a 2×2 contingency table, proposed by George A. Barnard in 1945.
Unlike Fisher's exact test, it does not condition on both margins being fixed, which can make it more powerful when the column totals are not set by the study design. Its p-value is obtained by maximizing over the unknown common success probability, so the test keeps the nominal Type I error rate.
The intuition behind the method
Suppose a trial compares the rate of a binary outcome between a treatment group and a control group. Fisher's exact test conditions on the observed margins, including the total number of successes. That is a stronger assumption than the design often implies when only the group sizes were fixed in advance. Barnard's test does not condition on that total. Instead, it considers every possible value of the common success probability under the null hypothesis (the nuisance parameter) and takes the largest tail probability across those values as the p-value. Because the nuisance parameter is handled by maximization rather than conditioned away, the test can be more powerful than Fisher's in settings where its assumptions fit, an advantage that Lydersen, Fagerland and Laake (2009) report for moderate to small samples.
History
George A. Barnard introduced the test in a short 1945 note in Nature. Suissa and Shuster (1985) used maximization over the nuisance parameter to eliminate it in the comparison of two proportions, in the context of exact unconditional sample sizes for the 2×2 binomial trial. Lydersen, Fagerland and Laake (2009) reviewed and recommended tests for association in 2×2 tables and concluded that unconditional tests preserve the significance level and are generally more powerful than Fisher's exact test for moderate to small samples. They also argued that the traditional Fisher's exact test should practically never be used.
When to use it
Use Barnard's exact test to compare two independent groups on a binary outcome when at least one cell count is small (commonly below 5), so that large-sample chi-squared approximations may be unreliable. It fits designs in which only the group sizes are fixed in advance, as in many randomized controlled trials and prospective cohort studies, while the column totals are free to vary. Do not use it when both margins are fixed by the design; Fisher's exact test is the appropriate reference in that case. It is also not the right tool for matched-pair data, where McNemar's test applies, or for tables larger than 2×2.
Limitations and considerations
- Computationally heavier than Fisher's test or the chi-squared test, because the p-value requires maximizing the tail probability over the nuisance parameter. This was a practical barrier in the past; Lydersen, Fagerland and Laake (2009) note that software for unconditional tests is now available.
- Because the data are discrete, the actual Type I error rate may fall below α in some configurations, making the test conservative there.
- Not valid when both margins are fixed by design; Fisher's exact test is the appropriate choice in that case.
- Results can depend on which statistic is used to order the tables, so different implementations may return different p-values.
Source conditions do not replace independent scientific review or validation by an analysis engine.
Strengths
- Generally more powerful than Fisher's exact test when the column totals are not fixed by design, with the advantage reported for moderate to small samples (Lydersen, Fagerland and Laake, 2009).
- Its p-value is exact in the sense that it preserves the significance level: the actual Type I error does not exceed the nominal α.
- It does not rely on large-sample approximations, so it can be applied to small 2×2 tables where the chi-squared approximation may not hold.
- Its reference distribution matches prospective designs in which only the group sizes are set in advance.
Applications
- Randomized controlled trials comparing binary event rates (e.g., adverse events, treatment response) between a treatment arm and a control arm with small sample sizes.
- Epidemiological cohort studies testing whether exposure is associated with a binary disease outcome when cell counts are sparse.
- Phase I/II clinical trials where group sizes are small and chi-squared approximations break down.
- Veterinary and ecological studies comparing binary outcomes (e.g., survival, infection) across two independent groups with limited observations.
- Quality-control and reliability settings comparing defect rates between two production lines when batch sizes are small.
How it works
How it works
The null hypothesis states that the two groups share the same underlying success probability; the alternative states that they differ. The direction of the alternative determines whether a one-sided or two-sided test is performed.
Formula
H_0:\ p_1 = p_2 \quad H_1:\ p_1 \neq p_2
A pooled-proportion z statistic is computed from the 2×2 table: the difference between the two sample proportions is divided by a standard error based on the pooled proportion p̂ = (x₁ + x₂)/(n₁ + n₂). The statistic is undefined when p̂ equals 0 or 1, because the standard error in the denominator is then zero; such tables must be handled separately, and the documentation of the software in use should be consulted for how they are treated. Other statistics can be used to order the tables, and the choice changes the resulting p-value, as noted under limitations.
Formula
T(\mathbf{x}) = \dfrac{\hat{p}_1 - \hat{p}_2}{\sqrt{\hat{p}(1-\hat{p})\left(\dfrac{1}{n_1}+\dfrac{1}{n_2}\right)}}, \quad \hat{p} = \dfrac{x_1 + x_2}{n_1 + n_2}The p-value is the supremum, over all values of the common nuisance parameter π between 0 and 1, of the summed exact binomial probabilities of the table configurations whose statistic is at least as extreme as the observed one. Maximizing over π removes the nuisance parameter without conditioning on the margins, which is what makes the test unconditional. Because the maximized tail probability bounds the Type I error across all values of π, the test keeps its nominal significance level. Because the maximization is computationally demanding (Lydersen, Fagerland and Laake, 2009), it is typically carried out numerically by statistical software, and the software used should be stated when the result is reported.
Formula
p = \sup_{0 < \pi < 1}\; \sum_{\mathbf{t}:\, T(\mathbf{t}) \geq T(\mathbf{x}_{\text{obs}})} \binom{n_1}{t_1}\pi^{t_1}(1-\pi)^{n_1-t_1} \binom{n_2}{t_2}\pi^{t_2}(1-\pi)^{n_2-t_2}If the computed p-value is below the chosen significance level α (typically 0.05), the null hypothesis of equal proportions is rejected. Because the test preserves the significance level, the actual Type I error does not exceed α, and the test is generally more powerful than Fisher's exact test at the same α for moderate to small samples. The test yields a p-value and does not by itself estimate the difference between the two proportions; a confidence interval for that difference requires a separate method.
Formula
\text{reject } H_0 \text{ if } p < \alphaCommon pitfalls
- Applying Barnard's test when both margins are fixed by design. This violates the unconditional framework, and Fisher's test should be used instead.
- Confusing Barnard's unconditional test with Fisher's conditional test. They rest on different probability models and should not be used interchangeably.
- Overlooking the choice of ordering statistic. The pooled-z version is one valid implementation among others, and software packages may differ in which statistic they use.
- Using a one-sided variant without a pre-registered directional hypothesis, which risks inflating the false-positive rate.
Frequently asked questions
Why is Barnard's test more powerful than Fisher's exact test?
Fisher's exact test conditions on both the row and column totals being fixed, including the total number of successes. Barnard's test treats the common success probability as a nuisance parameter and maximizes the tail probability over it, so it does not condition on that total. Dropping that conditioning is the reason the test can be more powerful, an advantage Lydersen, Fagerland and Laake (2009) report for moderate to small samples. This applies when only the group sizes are fixed by design.
When should I still prefer Fisher's exact test?
Use Fisher's exact test when both sets of marginal totals are genuinely fixed before data collection, for example in a study where the numbers in each group and the number of exposed cases are both predetermined. In that design the conditional distribution is the correct reference, and Barnard's test would not be appropriate.
What is the Boschloo test and how does it relate to Barnard's test?
The Boschloo test is another unconditional exact test for 2×2 tables and belongs to the same unconditional family as Barnard's test. A dedicated comparison of the two tests' properties is the best guide to choosing between them.
Does the test require equal group sizes?
No. Barnard's test is not restricted to equal group sizes. Its power depends on the group sizes n₁ and n₂ and on the true proportions.
Sources
Barnard, G. A. (1945). A new test for 2×2 tables. Nature, 156(3954), 177.
Open DOI referenceSuissa, S., & Shuster, J. J. (1985). Exact unconditional sample sizes for the 2×2 binomial trial. Journal of the Royal Statistical Society, Series A, 148(4), 317–327.
Open DOI referenceLydersen, S., Fagerland, M. W., & Laake, P. (2009). Recommended tests for association in 2×2 tables. Statistics in Medicine, 28(7), 1159–1175.
Open DOI reference