Bayesian Cross-Tabulation Analysis

Statistics
Introduced by
Gunel & Dickey
Year
1974
Type
Bayesian association test
Family
Classical statistics

What does it do?

Bayesian cross-tabulation analysis tests whether two categorical variables are associated by computing a Bayes factor that compares an association model with an independence model for the counts in a contingency table.

Unlike the classical chi-square test, it gives a graded measure of evidence, can quantify support for independence itself, and allows prior information about cell probabilities to be stated explicitly. The default framework for this analysis is the one introduced by Gunel and Dickey.

The intuition behind the method

Imagine a standard contingency table: rows for one categorical variable, columns for another, and counts in each cell. The classical approach computes a p-value and either rejects or fails to reject independence. The Bayesian approach instead asks: how much more probable are the observed counts under an association model than under an independence model? That ratio — the Bayes factor — can favour the null, favour the alternative, or declare the evidence inconclusive, giving a richer summary than a binary reject/fail verdict.

History

Gunel and Dickey (1974) derived Bayes factors for independence in contingency tables, showing that they factorise and expose the evidence in the marginal rows and columns. Jamil et al. later described default versions of these Bayes factors and reported that the code was incorporated into the BayesFactor R package and into JASP.

When to use it

Use Bayesian cross-tabulation when your data are counts in a contingency table of two or more categorical variables and the question is whether those variables are associated. It is most useful when you need evidence for independence and not only evidence against it, or when prior information about the cell probabilities should be stated explicitly. Choose the sampling model that matches how the data were collected, because the Gunel–Dickey prior depends on it. Do not use it for continuous outcomes unless they are first binned into categories, which discards information. Do not use it where the audience requires classical p-values and no Bayesian reporting is acceptable. The independence model does not use the order of categories, so when the ordering of ordinal categories is the question of interest, another approach is more suitable.

Limitations and considerations

  • Bayes factors depend on the prior concentration hyperparameter, and this dependence can matter more when tables are sparse.
  • The thresholds on Jeffreys' scale are conventions for describing evidence, not decision rules, and they do not carry over automatically to every application.
  • Editors and reviewers in many applied fields are more familiar with classical p-values, so the reporting of Bayes factors may need explanation.
  • The default Bayes factors are defined for the sampling models covered by Gunel and Dickey. Designs outside those models, and high-dimensional tables, may need other methods or computation.
  • The independence model treats categories as unordered, so information about category order is not used.

Source conditions do not replace independent scientific review or validation by an analysis engine.

Strengths

  • The Bayes factor compares the data under both models, so it can provide evidence for independence as well as against it.
  • For independence, the Gunel–Dickey Bayes factors factorise, which exposes the evidence in the row and column marginals of the table separately.
  • The default Bayes factors are a published and documented framework (Gunel and Dickey; Jamil et al.), so results can be reported against a standard reference setting.
  • Default priors can be used without subjective elicitation, and the computation is implemented in both the BayesFactor R package and JASP.

Applications

  • Testing whether survey response categories are independent of respondent demographic groups.
  • Assessing the association between treatment assignment and binary outcome categories in trial data, with the sampling model stated explicitly.
  • Analysing 2x2 tables from case-control studies when a Bayesian statement of evidence for or against independence is wanted alongside, or instead of, a Fisher's exact p-value.
  • Testing association in r x c tables of nominal variables, such as occupation by region.

How it works

How it works

1

Two competing models are specified. Under H0 (independence), the joint cell probabilities factorise into row and column marginal probabilities. Under H1 (association), the cell probabilities are unrestricted. Both models are given prior distributions over the cell probabilities, typically symmetric Dirichlet priors in the Gunel–Dickey approach.

Formula
H_0: \text{independence} \quad H_1: \text{association}
2

The prior for the cell probabilities is a Dirichlet distribution with concentration hyperparameters alpha. A value of alpha = 1 is the reference setting used on this page; confirm the value that your software uses. The form of the constrained prior depends on the sampling model, such as the multinomial, independent multinomial or hypergeometric model named on this page, so the sampling design must be identified before the prior is applied. These models differ in which totals the design fixes in advance: multinomial sampling fixes only the total sample size, independent multinomial sampling fixes the totals of one margin (for example each row), and hypergeometric sampling fixes both row and column totals. Gunel and Dickey relate the sampling models by nested conditioning, so the choice follows from how the data were collected.

Formula
\pi(\mathbf{p}) \propto \prod_{ij} p_{ij}^{\alpha_{ij}-1}
3

The Bayes factor BF10 is the ratio of the marginal likelihoods of the data under H1 and H0. On the scale used on this page, values above 3 suggest moderate evidence for association and values above 10 suggest strong evidence; values below 1/3 support independence. Gunel and Dickey showed that Bayes factors for independence factorise, so the evidence residing in the row and column margins can be seen separately. The default Bayes factors are implemented in the BayesFactor R package and in JASP (Jamil et al.), so the user can obtain them without deriving the marginal likelihoods by hand. Their reach to unusual designs depends on the sampling model and the table shape, as noted under limitations.

Formula
\text{BF}_{10} = \frac{P(\text{data} \mid H_1)}{P(\text{data} \mid H_0)}
4

After the data are observed, the posterior distributions over the cell probabilities are updated. Under the multinomial sampling model, the Dirichlet prior is conjugate to the likelihood, so the posterior is again Dirichlet, with the observed cell counts added to the prior concentration parameters. Posterior summaries, such as credible intervals for row and column proportions, odds ratios and relative risks, describe the direction and size of any association that the Bayes factor identifies.

5

The analyst reports BF10 together with its verbal label on Jeffreys' conventional scale, using the thresholds given above, and together with posterior summaries of the association. Inconclusive evidence is reported as such, rather than being forced into a reject or retain decision.

Common pitfalls

  • Reading BF10 = 1 as evidence that there is no association. It means the data do not discriminate between the two models, not that H0 is true.
  • Ignoring the sampling model (multinomial, independent multinomial or hypergeometric). The correct Gunel–Dickey prior depends on how the data were collected.
  • Reporting only the Bayes factor without posterior summaries of the size and direction of the association. Evidence strength and effect description should be reported together.
  • Choosing very large or very small alpha values without justification, which can dominate the Bayes factor, particularly in small samples. Report BF10 across a stated range of alpha values as a sensitivity check.

Frequently asked questions

How does Bayesian cross-tabulation differ from the classical chi-square test?

The chi-square test computes a p-value, the probability of data at least this extreme if independence were true, and rejects H0 if p < 0.05. Bayesian cross-tabulation computes a Bayes factor, which directly compares the probability of the data under the association model with its probability under the independence model. This allows you to quantify evidence for independence itself, not only against it.

What does a Bayes factor of 5 mean?

BF10 = 5 means the data are five times more probable under the association model than under the independence model. Following Jeffreys' conventional scale, values between 3 and 10 are read as moderate evidence for association. The reciprocal BF01 = 0.2 would indicate moderate evidence for independence.

Which prior should I use?

A default Gunel–Dickey prior is a reasonable starting point for many applied analyses, with alpha = 1 as the reference value on this page; confirm the value used by your software. If you have genuine prior knowledge about expected cell proportions, a sensitivity analysis across a stated range of alpha values is advisable.

Can I use this for tables larger than 2x2?

Yes. The Gunel–Dickey framework extends to r x c tables. Sparse tables, in which many cells hold few counts, make the prior more influential on the Bayes factor, so prior specification and interpretation become more difficult. In those cases consider collapsing categories, checking sensitivity to alpha, or using an exact method.

Is Bayesian cross-tabulation available in standard software?

Yes. JASP provides a point-and-click interface, and the BayesFactor package in R offers the same analysis with greater flexibility for prior specification and output.

Related methods

Sources

  1. Gunel, E., & Dickey, J. (1974). Bayes factors for independence in contingency tables. Biometrika, 61(3), 545–557.

    Open DOI reference
  2. Jamil, 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