Test selection · ~7 min read
R by C Contingency Tables: When Chi-Square and Fisher's Exact Aren't Enough
Add one more category to either axis, and the rule that worked for your 2×2 table can quietly stop applying.
Published
In short
An R×C contingency table, more than two rows or more than two columns, does not automatically qualify for a standard chi-square test just because a 2×2 table would. The same rule decides it either way, every expected cell count at least 5,1 but a bigger table has more cells to fill from the same sample, so that threshold is easier to fail as the table grows. Below is a real 3×2 result where the standard chi-square is valid, an illustrative case where it isn't, and what StatsPlease does differently in each case.
Why a bigger table isn't just a bigger 2×2
A 2×2 table has four cells. A 3×3 table has nine. The same total sample size now has more than double the number of cells to fill, and a chi-square test's reliability depends on the expected count in every one of those cells, not just the overall N.2 Two studies with identical sample sizes can land on opposite sides of the threshold purely because one crossed a two-category exposure against a two-category outcome and the other crossed a three-category exposure against a three-category outcome.
The test itself doesn't change. Pearson's chi-square statistic and its degrees of freedom, (rows−1)×(columns−1), are computed the same way regardless of table size. What changes is how much scrutiny the expected-cell-count check deserves before you trust the P value it returns.
A real result: does ulceration predict how melanoma patients die?
In a cohort of 205 patients operated for malignant melanoma in Denmark, each patient's eventual status was recorded as one of three outcomes: died from melanoma, alive at last follow-up, or died from an unrelated cause.4 Ulceration of the primary tumor is a well-established prognostic marker. Crossing the three-level outcome against ulceration (present or absent) gives a genuine 3×2 table.
| Outcome | Ulcer absent | Ulcer present |
|---|---|---|
| Died from melanoma | 16 | 41 |
| Alive | 92 | 42 |
| Died, other causes | 7 | 7 |
Expected counts range from 6.15 to 75.17; every cell clears 5, so the standard chi-square applies without a fallback.
χ2(2) = 26.97 · P < .001 · Cramér's V = 0.36 (medium)
Outcome status was significantly associated with tumor ulceration (χ2[2] = 26.97, P < .001, Cramér's V = 0.36). Bias-corrected Cramér's V = 0.35.
Figures computed with scipy from real cohort data (n = 205).
Example data: melanoma cohort, Odense, Denmark (Andersen, Borgan, Gill, and Keiding, 1993); see references. Computed with scipy, not generated.
Every expected count in this table, even the smallest, "died from other causes" crossed with "ulcer absent", clears 5. That's what licenses the standard chi-square P value above. Nothing here requires Fisher's exact or its larger-table extension. This is the table doing what a 3×2 table is allowed to do when the sample is large enough to support it.
When the table doesn't qualify for chi-square
Shrink the sample and widen the table, and the same arithmetic stops being trustworthy. Suppose a single-centre series compares three surgical approaches against complication grade: none, minor, or major.
| None | Minor | Major | |
|---|---|---|---|
| Approach A | 11 | 3 | 1 |
| Approach B | 10 | 2 | 1 |
| Approach C | 6 | 4 | 2 |
With only 40 patients spread across nine cells, six of the nine expected counts fall below 5, two-thirds of the table. Cochran's rule says not to trust the standard chi-square P value here.2 The 2×2 fallback, Fisher's exact test, doesn't directly extend to a 3×3 table by the same closed-form calculation. Its generalization, the Freeman-Halton extension, is exact in principle, but the computation grows combinatorially with table size, so most statistical software approximates or simulates it once a table is this large or sparse rather than enumerating every possible table directly.3 StatsPlease's engine checks the same expected-count threshold automatically and routes a sparse table like this one to a Monte-Carlo permutation chi-square instead of reporting the unreliable Pearson P value.
Writing the AMA sentence
State which test the table actually supported, not which one you defaulted to. If every expected count cleared 5, say the standard chi-square applied without qualification. If the table was sparse, name the fallback and why: "because more than 20% of expected cell counts fell below 5, an exact or Monte-Carlo test was used in place of the standard chi-square approximation." A reviewer checking your table against Cochran's threshold should reach the same conclusion you did.
Try it yourself
Reproduce this result
The melanoma example above was computed from a public cohort. Run it in either tool and the numbers match, because both are doing the same computation, not generating it.
In StatsPlease
- Upload the dataset as a CSV.
- Open the Analysis tab.
- Select the two categorical variables as Outcome: status and ulcer. No grouping variable is needed.
- Press the Category Patterns preset button. There is no separate run step; pressing the preset runs the analysis, checks expected cell counts across all six cells, and routes to the standard chi-square or a Monte-Carlo fallback.
- On the Results tab, the expected-cell check, the test actually used, and the AMA sentence are shown together.
In SPSS
- Analyze → Descriptive Statistics → Crosstabs. Row(s): status; Column(s): ulcer.
- Statistics → Chi-square. Cells → Expected, to see every cell's expected count.
- Check whether any expected count falls below 5 before trusting the printed Pearson P value.
- SPSS's Crosstabs dialog does not offer a Freeman-Halton exact test for tables larger than 2x2 by default; an exact R×C test requires the separate Exact Tests module.
Frequently asked questions
What's the difference between a 2×2 chi-square and an R by C chi-square?
The arithmetic is the same chi-square test of independence either way. What changes is how many cells the sample size has to be spread across: a 2×2 table has 4 cells, a 3×3 has 9. More cells means smaller expected counts for the same N, so the reliability threshold is easier to fail as the table grows.
When does an R by C table need Fisher's exact instead of chi-square?
When too many cells have an expected count below 5, Cochran's classic threshold. For 2×2 tables Fisher's exact is a closed-form calculation. For larger tables the exact version is the Freeman-Halton extension, which most software approximates or simulates once the table is large or sparse, because the calculation grows combinatorially with table size.
Does a significant R by C chi-square tell you which categories are associated?
No. A significant chi-square is an omnibus result: it says the table as a whole departs from independence, not which specific row-column pairing drives it. Identifying that requires a follow-up step, such as inspecting standardized residuals or a planned pairwise comparison, the same way a significant ANOVA doesn't say which groups differ.
You might also read
References
- Cochran WG. Some methods for strengthening the common χ² tests. Biometrics. 1954;10(4):417-451. https://doi.org/10.2307/3001616
- Freeman GH, Halton JH. Note on an exact treatment of contingency, goodness of fit and other problems of significance. Biometrika. 1951;38(1-2):141-149. https://doi.org/10.1093/biomet/38.1-2.141
- Mehta CR, Patel NR. A network algorithm for performing Fisher's exact test in r × c contingency tables. Journal of the American Statistical Association. 1983;78(382):427-434. https://doi.org/10.1080/01621459.1983.10477989
- Andersen PK, Borgan Ø, Gill RD, Keiding N. Statistical Models Based on Counting Processes. New York, NY: Springer-Verlag; 1993. https://doi.org/10.1007/978-1-4612-4348-9
StatsPlease checks every expected cell count on your own uploaded table, no matter how many rows or columns, before choosing between the standard chi-square and an exact or Monte-Carlo fallback. Select your two categorical variables and press the Category Patterns preset; pressing it runs the analysis.
Try StatsPlease free