- Introduced by
- Karl Pearson
- Year
- 1900
- Type
- Descriptive and inferential categorical analysis
- Family
- Classical statistics
What does it do?
Cross-tabulation analysis (contingency table analysis) arranges the observed frequencies of two or more categorical variables into a table of rows and columns.
It allows the pattern of counts to be inspected directly and supports a chi-square test of independence between the variables.
The intuition behind the method
Imagine you want to know whether gender is associated with product preference. You count how many men and women chose each product option and arrange these counts into a table. If gender and preference are independent, the proportions should look similar across rows. Cross-tabulation makes this comparison concrete: you compare the actual cell counts with what you would expect under independence, and if the discrepancy is large enough, you conclude an association exists. The approach works for any pair of categorical variables, from survey responses to clinical outcomes to market segments.
History
Karl Pearson's 1900 paper introduced the chi-square criterion, which underlies the test of independence applied to contingency tables. Exact alternatives, such as Fisher's exact test, are used when expected counts are small. Agresti's 2002 book on categorical data analysis is a standard reference for these methods.
When to use it
Use cross-tabulation whenever you want to describe or test the association between two categorical variables on the same cases — for example, comparing treatment versus control on a categorical outcome, examining whether two survey items co-vary, or checking demographic differences in categorical responses. Both variables must be categorical (nominal or ordinal). A commonly used working convention is that at least 80 percent of cells have expected counts of 5 or more; when this is not met, see the expected-counts step. Do not use cross-tabulation for continuous outcomes (use t-tests or ANOVA), for more than two variables simultaneously without log-linear or logistic-regression modeling, or as a substitute for measures of agreement when the same raters rate the same objects.
Limitations and considerations
- Assumes independent observations, each case contributing to one cell; repeated measures or matched pairs need a different analysis.
- The chi-square approximation is unreliable when many cells have expected counts below 5.
- Detects association but does not establish the direction of causation or control for confounders.
- With many categories or variables the table becomes large and hard to interpret, and a significant overall test does not identify which cells drive the result.
- Collapsing ordinal categories into fewer levels to meet cell-count requirements can discard information.
Source conditions do not replace independent scientific review or validation by an analysis engine.
Strengths
- Straightforward to compute, and the observed counts and percentages can be read directly from the table, which makes results easy to communicate to non-statistical audiences.
- Applies to any number of categories in each variable without assuming a particular distribution for the variables; the chi-square p-value itself relies on a large-sample approximation (see limitations).
- Provides both a descriptive view (observed and percentage tables) and a formal significance test.
- Pairs with effect-size measures such as the phi coefficient, Cramer's V, and the odds ratio for 2 x 2 tables, which go beyond the p-value.
- Fisher's exact test is available as an alternative when the sample is small or cells are sparse.
Applications
- Analyzing survey data to determine whether demographic groups (age, gender, education) differ in categorical responses.
- Clinical research: comparing treatment and control groups on categorical outcomes such as recovery, no recovery.
- Market research: examining whether product preference differs across customer segments.
- Epidemiology: assessing whether exposure (yes/no) is associated with disease status (yes/no), computing odds ratios.
- Educational research: comparing pass/fail rates across instructional methods or institutions.
- Quality control: checking whether defect categories differ across production lines or shifts.
How it works
How it works
The data are arranged into an r x c contingency table where rows represent categories of one variable and columns represent categories of the other. Each cell records the count of observations falling into that combination of categories. Row totals, column totals, and the grand total N are computed. Cell percentages (row, column, or total) are also reported to aid interpretation.
Under the null hypothesis of independence, the expected count for cell (i, j) is the product of its row marginal total R_i and column marginal total C_j, divided by the grand total N. A commonly used working convention, rather than a fixed requirement, is that at least 80 percent of cells have expected counts of 5 or more. When this convention is not met, or when any single cell has a very small expected count, the chi-square approximation becomes unreliable, and Fisher's exact test or collapsing categories should be considered.
Formula
E_{ij} = \dfrac{R_i \times C_j}{N}The chi-square statistic sums, over all cells, the squared difference between each observed count O_ij and its expected count E_ij divided by E_ij. A large chi-square value indicates systematic departure from independence.
Formula
\chi^2 = \sum_{i,j} \dfrac{(O_{ij} - E_{ij})^2}{E_{ij}}The degrees of freedom equal the number of rows minus one multiplied by the number of columns minus one. This quantity determines which chi-square distribution is used to obtain the p-value.
Formula
df = (r - 1)(c - 1)
If the p-value is below 0.05, the null hypothesis of independence is rejected and an association is declared. The 0.05 cut-off is a convention rather than a property of the test, so the p-value should be read alongside the size of the association. That size is quantified with measures such as Cramer's V, the phi coefficient for 2 x 2 tables, or the odds ratio.
Formula
\text{reject } H_0 \text{ if } p < 0.05Common pitfalls
- Reporting only the chi-square p-value without an effect size such as phi or Cramer's V. Statistical significance grows with sample size, so a trivial association can be significant in a large sample.
- Relying on the standard chi-square test when the working convention on expected counts (at least 80 percent of cells at 5 or more) is not met, or when a cell has a very small expected count. Apply Fisher's exact test or collapse categories instead.
- Treating a significant chi-square as evidence of a specific direction of association without inspecting the cell percentages or the standardized residuals.
- Comparing row percentages with column percentages inconsistently, which can produce contradictory descriptions of the same table.
- Ignoring the ordinal nature of ordered categories. Rank-based or trend tests that use the ordering of the categories are more suitable when order matters.
Frequently asked questions
When should I use Fisher's exact test instead of the chi-square test?
Use Fisher's exact test when the chi-square approximation is not reliable under the expected-count convention described above, typically because the sample is small or cells are sparse. Fisher's test calculates the exact probability of the observed table and all more extreme tables, without relying on the chi-square approximation. For larger tables with sparse cells, consider collapsing categories or using Monte Carlo simulation of the p-value.
How do I measure the strength of the association?
For 2 x 2 tables the phi coefficient measures the association and is interpreted on a scale similar to a correlation. For larger tables, use Cramer's V, which adjusts for table dimensions. Values near zero indicate a weak association. There is no universal cut-off separating moderate from strong, so interpretation should depend on the subject area and on the size of the differences in the table.
Does a significant chi-square tell me which cells drive the association?
Not directly. Inspect the standardized residuals for each cell, defined here as the difference between observed and expected counts divided by its standard error. Residuals with absolute value above 2 flag the cells that contribute most to a significant chi-square.
Can I use cross-tabulation with ordinal variables?
Yes, but the standard chi-square test ignores order. When both variables are ordinal, a trend test that uses the ordering of the categories, or measures such as gamma and Kendall's tau-b, are more appropriate because they use the ordering and can detect monotone association that the standard test may miss.
Is cross-tabulation the same as frequency analysis?
Frequency analysis typically tabulates one variable at a time (a one-way frequency table). Cross-tabulation extends this to two or more variables simultaneously, producing a two-way (or higher-order) table that reveals how categories of different variables co-occur.
Related methods
Sources
Pearson, K. (1900). On the criterion that a given system of deviations from the probable in the case of a correlated system of variables is such that it can be reasonably supposed to have arisen from random sampling. Philosophical Magazine, 50(302), 157–175.
Open DOI referenceAgresti, A. (2002). Categorical Data Analysis (2nd ed.). Wiley-Interscience.
ISBN: 978-0471360933