- Introduced by
- Gunel & Dickey (Bayesian form); R. A. Fisher (classical exact test)
- Year
- 1974 (Bayesian form); 1935 (Fisher's exact test)
- Type
- Bayesian hypothesis test for independence
- Family
- Classical statistics
What does it do?
The Bayesian Fisher's exact test evaluates independence between two categorical variables in a 2x2 table by computing a Bayes factor rather than a p-value.
Using conjugate priors on the cell probabilities, most commonly within the Gunel-Dickey framework, it quantifies how much more or less probable the observed counts are under an association model than under an independence model. The result is a continuous measure of evidence that can favour either hypothesis.
The intuition behind the method
The classical Fisher's exact test gives a p-value and a reject-or-not decision. The Bayesian version gives a Bayes factor, which states how much more probable the data are under the association hypothesis than under independence, or the reverse. A Bayes factor of 10 means the data are ten times more likely if an association exists; a value of 0.1 means they are ten times more likely under independence. Because the comparison is symmetric, the test can give formal evidence for the null, which a p-value cannot.
History
R. A. Fisher introduced the exact test for 2x2 tables in 1935, a test valid at any sample size because it enumerates all tables with the same margins. Gunel and Dickey's 1974 Biometrika paper, Bayes Factors for Independence in Contingency Tables, derived Bayes factors for row-column independence under several sampling models related by nested conditioning. Jamil and colleagues later provided default Bayes factors for contingency tables, built on the Gunel-Dickey sampling models, and their code was incorporated into the BayesFactor R package and the JASP program.
When to use it
Use the Bayesian Fisher's exact test when your data form a 2x2 contingency table, that is two binary categorical variables, especially with small cell counts where the asymptotic chi-square approximation is unreliable. It is a good choice when you want evidence for independence and not only a rejection of it, when you want to track evidence as data accumulate across studies, or when your analysis already follows a Bayesian framework. This page covers only the 2x2 case. Default Gunel-Dickey Bayes factors for R×C tables are presented by Jamil et al. (2017), and those tables fall outside the scope described here. If all cell counts are large and the asymptotic approximation is adequate, the classical chi-square test is simpler. For ordinal variables, rank-based tests are more appropriate.
Limitations and considerations
- Restricted to 2x2 tables on this page. Default Gunel-Dickey Bayes factors for R×C tables are presented by Jamil et al. (2017); the sampling models and computation for those tables are not described here.
- The Bayes factor depends on the prior, including its concentration parameter, so a sensitivity analysis is needed before conclusions are reported.
- The sampling model (multinomial, independent-multinomial, or hypergeometric) changes the Bayes factor, and the correct choice follows from the study design, which is not always clear from the data.
- Reviewers trained mainly in frequentist methods may need an explanation of Bayes factors and of the prior choice.
Source conditions do not replace independent scientific review or validation by an analysis engine.
Strengths
- Quantifies evidence for both association and independence on a continuous scale, whereas a p-value only allows rejection of the null hypothesis of independence.
- Uses exact computation rather than an asymptotic approximation, so it remains usable when some cells have small or zero counts.
- Under the Gunel-Dickey framework the Bayes factors factorize, which exposes the evidence in the marginal row and column totals, so the same inputs and prior settings reproduce the same result.
- Posterior model probabilities give direct statements about independence versus association, instead of a decision defined relative to a significance level.
Applications
- Small comparisons of a binary outcome between two groups, such as pilot studies with few events in some cells.
- Sparse 2x2 tables from case-control or cohort data, where asymptotic chi-square tests are unreliable.
- Sequential studies in which the evidence about an association is tracked as data accrue.
- Replication studies where the question is whether an association is present or absent, so that evidence for independence is of direct interest.
- Teaching and sensitivity analyses that compare how conclusions change with the prior concentration.
How it works
How it works
The data are a 2x2 table of counts. Gunel and Dickey (1974) consider four sampling models for a two-way table, related to one another by nested conditioning, and the Bayes factor depends on which model describes the study design. This page discusses three of them: multinomial sampling (total N fixed), independent-multinomial sampling (one set of margins fixed), and hypergeometric sampling (both margins fixed). The fourth model is not covered here. This page does not give a rule for mapping a study design to a sampling model. Take that mapping from Gunel and Dickey (1974) and Jamil et al. (2017), and verify it before reporting a Bayes factor, because the choice of sampling model changes the result.
Formula
n_{ij} \text{ in } 2 \times 2 \text{ table; } M_0: \text{independence vs } M_1: \text{association}Conjugate Beta (or Dirichlet-type) priors are placed on the cell probabilities under both the independence model and the association model. In the Gunel-Dickey framework, the prior in one sampling model induces the priors in the models conditioned from it, so the prior is tied to the chosen sampling model. The framework supplies default prior settings, but the default concentration value is not reproduced on this page; confirm it in Jamil et al. (2017) before use. Users may substitute informative priors when they have knowledge about the likely strength of association. Whichever prior is used, vary the concentration parameter of the Beta or Dirichlet prior in a sensitivity analysis.
Formula
\pi(\theta \mid M_k) \propto \text{Beta/Dirichlet prior on cell probabilities}The marginal likelihood of the observed table under each model is obtained by integrating the sampling likelihood over the prior on the cell probabilities. Gunel and Dickey show that the Bayes factors for independence factorize, which exposes the evidence residing in the marginal row and column totals of the table. The exact expression for the chosen sampling model should be checked against the original derivation before it is reported.
Formula
p(\mathbf{n} \mid M_k) = \int p(\mathbf{n} \mid \theta, M_k)\, \pi(\theta \mid M_k)\, d\thetaThe Bayes factor BF10 is the ratio of marginal likelihoods: evidence for association divided by evidence for independence. Values above 1 support association; values below 1 support independence. Jeffreys' conventional scale describes graded strength of evidence: BF10 between 1 and 3 is anecdotal evidence for association, 3 to 10 is moderate, and above 10 is strong. BF10 below 1/3 is moderate evidence for independence. These are graded categories, not decision thresholds.
Formula
BF_{10} = \frac{p(\mathbf{n} \mid M_1)}{p(\mathbf{n} \mid M_0)}Report BF10 with its graded interpretation on Jeffreys' scale, together with the posterior probability of each model given equal prior model probabilities. Treat the categories as descriptions of the strength of evidence, not as a significance cut-off. For a sensitivity analysis, vary the prior concentration parameter to confirm that conclusions are robust to the prior choice.
Formula
BF_{10} > 3: \text{moderate evidence for association};\quad BF_{10} < 1/3: \text{evidence for independence}Common pitfalls
- Choosing the prior without regard to the sampling scheme. Under the Gunel-Dickey framework the prior is tied to the sampling model, so a prior taken from a different sampling model gives an inconsistent Bayes factor.
- Treating BF10 > 3 as a hard decision threshold analogous to p < 0.05. The Jeffreys categories describe the strength of evidence and should be interpreted alongside the context of the study.
- Applying the test to a 2x2 table taken from a larger multi-way table without considering how that subtable was selected, which can change the question being tested.
- Confusing BF10 (evidence for association over independence) with BF01, its reciprocal. Always state which direction is reported.
Frequently asked questions
How is this different from the classical Fisher's exact test?
The classical test computes a p-value, the probability of a table as extreme as the one observed under the null, and rejects when p < 0.05. The Bayesian version computes a Bayes factor that quantifies the relative evidence for association versus independence. Unlike the p-value, the Bayes factor can provide formal evidence in favour of independence, and it depends on the prior as well as on the sample.
Which prior should I use?
The Gunel-Dickey framework provides default settings, implemented in JASP and the BayesFactor R package (Jamil et al., 2017). They are tied to the chosen sampling model. Confirm the default values in Jamil et al. before relying on them. If you have substantive knowledge about the likely strength of association, you can use an informative prior; then confirm that the conclusion holds across a range of concentration settings in a sensitivity analysis.
What Bayes factor value indicates a meaningful result?
Jeffreys' scale is widely used: BF10 between 1 and 3 is anecdotal evidence for association, 3 to 10 is moderate, and above 10 is strong. Symmetrically, BF10 below 1/3 is moderate evidence for independence. These are interpretive guidelines, not decision thresholds, so report the Bayes factor as a continuous measure alongside the posterior model probabilities.
Can I use this test when one or more cells have zero counts?
Yes, in principle. The Bayes factor is computed from marginal likelihoods rather than from an asymptotic chi-square approximation, so the sample-size requirements of that approximation do not apply. Check the documentation of the implementation you use for how it handles zero cells.
Where is it implemented?
JASP offers a Bayesian contingency-table test based on the Gunel-Dickey models through a point-and-click interface. The BayesFactor R package implements the same Bayes factors. Jamil et al. (2017) give the sampling models and default Bayes factors in detail for custom implementations.
Related methods
Sources
Gunel, E., & Dickey, J. (1974). Bayes factors for independence in contingency tables. Biometrika, 61(3), 545–557.
Open DOI referenceJamil, T., Ly, A., Morey, R. D., Love, J., Marsman, M., & Wagenmakers, E.-J. (2017). Default Gunel and Dickey Bayes factors for contingency tables. Behavior Research Methods, 49(2), 638–652.
Open DOI reference