Categorical Data in Medical Research
Categorical data is any variable that falls into distinct, non-overlapping groups. In clinical research, this is the most common type of outcome data you will encounter: a patient either developed a surgical site infection or did not; a drug trial participant either responded to treatment or did not; a histopathology specimen is either positive or negative for a biomarker. When you want to test whether the distribution of these categorical outcomes differs between two or more groups, you need a test designed specifically for categorical data not a t test, not ANOVA.
The two workhorse tests for this purpose are the Chi-Square test of independence and Fisher's Exact Test. Both are applied to data arranged in a contingency table a grid that cross-tabulates two categorical variables and shows the count of observations in each combination of categories.
What Is the Chi-Square Test?
The Chi-Square test of independence was developed by Karl Pearson in 1900 and remains the most widely used statistical test for categorical data in medical research. It tests whether the observed distribution of counts across categories differs significantly from what would be expected if the two variables were completely independent of each other.
The test works by calculating an expected frequency for every cell in the contingency table under the null hypothesis of independence, then quantifying how far the observed counts deviate from these expected values.
Expected frequency: E = (Row Total - Column Total) / Grand Total
A large 2 value means the observed counts deviate substantially from what independence would predict suggesting a real association between the two variables. The 2 statistic follows a chi-square distribution with degrees of freedom = (number of rows 1) - (number of columns 1). For a standard 2-2 table, df = 1.
Assumptions of the Chi-Square Test
Independence of observations
Each subject contributes to one and only one cell of the table. Chi-Square cannot be used for paired or matched data that requires McNemar's test.
Expected cell frequencies 5 in all cells
This is the most critical assumption. The Chi-Square test is based on a mathematical approximation that only holds when expected frequencies are large enough. When any expected frequency drops below 5, the approximation breaks down and the p-value becomes unreliable.
Adequate total sample size
For 2-2 tables, a minimum total n of 20 is generally recommended. For larger tables, at least 80% of cells should have expected frequencies 5, and no cell should have an expected frequency of zero.
Categorical, not continuous, data
Both variables must be categorical (nominal or ordinal). Do not use Chi-Square for continuous outcomes those require t-tests, ANOVA, or correlation.
What Is Fisher's Exact Test?
Fisher's Exact Test was developed by Ronald Fisher in 1922, originally to analyze the famous "Lady Tasting Tea" experiment. Unlike Chi-Square, which calculates an approximated probability from a continuous distribution, Fisher's Exact Test calculates the exact probability of observing your specific table configuration and all configurations more extreme directly from the hypergeometric distribution. No approximation is involved, which is why the word "exact" appears in its name.
The calculation considers all possible 2-2 tables that could be formed with the same row and column totals as your observed data, then computes the exact probability of obtaining your observed result (or something more extreme) purely by chance. This makes it mathematically precise regardless of how small the expected cell frequencies are.
Assumptions of Fisher's Exact Test
Independence of observations
Same as Chi-Square each subject contributes to exactly one cell. Fisher's Exact Test cannot be used for paired data either.
Fixed marginal totals
Fisher's Exact Test was originally derived under the assumption that both row and column totals are fixed by design. In practice, this assumption is often relaxed, and the test is widely accepted and appropriate for any 2-2 categorical comparison with small samples.
Categorical, not continuous, data
Applies to binary or categorical outcomes only. Best suited to 2-2 tables; extensions to larger tables (Freeman-Halton test) exist but are less commonly used.
Key Differences Between Chi-Square and Fisher's Exact Test
Understanding these differences will make the choice between the two tests straightforward in any research context.
| Feature | Chi-Square Test | Fisher's Exact Test |
|---|---|---|
| Mathematical basis | Approximation via chi-square distribution | Exact probability via hypergeometric distribution |
| Expected frequency requirement | All cells must have E 5 | No minimum requirement |
| Best for sample size | Larger samples (n > 20 per group) | Small samples, rare events, pilot studies |
| P-value type | Approximate | Exact |
| Table size | Any size (2-2 to m-n) | Best for 2-2; extensions exist for larger |
| Statistical power | Higher when assumptions are met | Slightly more conservative (lower power) |
| Test statistic reported | 2, df, p-value | p-value (Fisher's exact); OR, 95% CI |
| Effect size | Cram(c)r's V or phi () | Odds Ratio (OR) with 95% CI |
| Software availability | All major packages (SPSS, R, SAS, Stata) | All major packages |
| Paired data variant | McNemar's test (not Chi-Square) | McNemar's test (not Fisher's) |
The Expected Frequency Rule How to Choose
The decision between Chi-Square and Fisher's Exact Test is governed by a single rule that applies universally, regardless of your study design or research question. This rule is based on the expected cell frequencies not the observed frequencies you collected, but the theoretical frequencies you would expect if there were no association at all.
Apply this calculation BEFORE running either test.
Step-by-Step Decision Process
Set up your contingency table with observed frequencies
Arrange your data in a 2-2 (or larger) table with row totals, column totals, and grand total clearly calculated.
Calculate the expected frequency for every cell
E = (Row Total - Column Total) / Grand Total. Do this for all cells not just the ones you suspect might be small.
Check every expected frequency against the threshold
If every single expected frequency is 5 or above proceed with Chi-Square. If even one expected frequency is below 5 use Fisher's Exact Test for the entire analysis.
Additional check: total sample size
If the total n in your 2-2 table is below 20 (regardless of expected frequencies), use Fisher's Exact Test as an additional safety measure. Very small totals make even technically adequate expected frequencies unreliable.
Contingency Table Examples With Expected Frequencies
Example 1: Chi-Square Is Appropriate
A surgeon investigates whether antibiotic prophylaxis reduces surgical site infections (SSI) in 200 elective abdominal procedures. Patients are randomized to antibiotic prophylaxis (n = 100) or no prophylaxis (control, n = 100).
| Group | SSI Developed | No SSI | Row Total |
|---|---|---|---|
| Antibiotic Prophylaxis | 8E = 13.0 | 92E = 87.0 | 100 |
| No Prophylaxis (Control) | 18E = 13.0 | 82E = 87.0 | 100 |
| Column Total | 26 | 174 | 200 |
Smallest expected frequency = 13.0 all cells 5 Chi-Square Test is appropriate.
Expected frequency calculation: E(Antibiotic/SSI) = (100 - 26) / 200 = 13.0. All four expected frequencies equal 13.0 or 87.0 well above the threshold of 5.
Result: 2(1) = 4.88, p = 0.027, = 0.156. Odds Ratio = 0.37 (95% CI: 0.15 to 0.88).
Example 2: Fisher's Exact Test Is Required
A pilot study tests a novel immunotherapy in 15 patients with a rare autoimmune condition 8 receive treatment, 7 serve as controls. The outcome is clinical remission at 6 months.
| Group | Remission | No Remission | Row Total |
|---|---|---|---|
| Immunotherapy | 5E = 3.73 | 3E = 4.27 | 8 |
| Control | 2E = 3.27 | 5E = 3.73 | 7 |
| Column Total | 7 | 8 | 15 |
Chi-Square is NOT valid here Fisher's Exact Test is required.
Expected frequency check: E(Treatment/Remission) = (8-7)/15 = 3.73; E(Treatment/No Remission) = (8-8)/15 = 4.27; E(Control/Remission) = (7-7)/15 = 3.27; E(Control/No Remission) = (7-8)/15 = 3.73. Every single cell falls below 5.
Result: Fisher's exact p = 0.282 (two-tailed). OR = 4.17 (95% CI: 0.4751.3).
Example 3: Larger Table 3-2 Contingency
A pathologist categorizes 90 colorectal cancer specimens into three differentiation grades (well, moderate, poor) and compares lymph node metastasis rates across grades. This is a 3-2 contingency table.
With a 3-2 table and adequate expected cell frequencies (all 5), Chi-Square remains the correct test. Fisher's Exact Test in its standard form is limited to 2-2 tables the Freeman-Halton extension exists for larger tables but is not available in all software packages and is rarely reported in clinical journals.
Key rule for larger tables: Chi-Square requires that no more than 20% of cells have expected frequencies < 5, and that no cell has an expected frequency of zero. If sparse cells are a problem, consider collapsing adjacent categories (e.g., combining moderate and poor differentiation) only when clinically and biologically justified.
Real Clinical Research Scenarios
Scenario 1 Parallel-Arm RCT With Adequate Sample (Chi-Square)
A pneumologist randomizes 240 community-acquired pneumonia patients to azithromycin (n = 120) versus amoxicillin-clavulanate (n = 120). Primary outcome: clinical cure at day 7 (yes/no).
Result: Azithromycin: 98/120 cured (81.7%). Amoxicillin-clavulanate: 91/120 cured (75.8%). All expected cell frequencies exceed 5 (minimum expected = 22.4). Chi-Square is appropriate.
Scenario 2 Small Case-Control Study of Rare Disease (Fisher's Exact)
An oncologist investigates whether BRCA1 mutation carrier status is associated with triple-negative breast cancer in a pilot case-control study. Cases: 14 triple-negative patients. Controls: 14 hormone-receptor-positive patients.
Observed: Cases: 9 BRCA1+, 5 BRCA1. Controls: 3 BRCA1+, 11 BRCA1. Expected frequency for Controls/BRCA1+ = (14 - 12) / 28 = 6.0. Expected frequency for Controls/BRCA1 = (14 - 16) / 28 = 8.0. Cases/BRCA1+: E = 6.0. Cases/BRCA1: E = 8.0. All 5, but n = 28 total borderline.
Scenario 3 Postgraduate Thesis Comparing Complication Rates (Chi-Square)
A surgical resident compares wound dehiscence rates between laparoscopic (n = 90) and open appendectomy (n = 90) in a retrospective cohort study for their master's thesis. Dehiscence rates: Laparoscopic 3/90 (3.3%), Open 11/90 (12.2%).
Expected frequency check: E(Laparoscopic/Dehiscence) = (90 - 14) / 180 = 7.0. All expected frequencies 5. Chi-Square is valid. 2(1) = 4.91, p = 0.027, = 0.165, OR = 0.24 (95% CI: 0.060.88).
Interpreting the P Value for Chi-Square and Fisher's Exact
The interpretation of the p-value follows the same logic regardless of which test you use. Both tests produce a p-value that represents the probability of observing a table configuration as extreme as or more extreme than the one you obtained, assuming the null hypothesis of no association is true. For a deeper understanding of p-value interpretation beyond categorical tests, read our guide on how to interpret p values in medical research.
- p < 0.05: You reject the null hypothesis of independence. There is statistically significant evidence of an association between your two categorical variables.
- p 0.05: You fail to reject the null hypothesis. The data do not provide sufficient evidence of an association. This does NOT prove there is no association only that your sample was not large enough to detect it with confidence.
- p is two-tailed by default: Most software reports a two-tailed p-value for Fisher's Exact. Some older papers report one-tailed p-values this is generally not recommended unless the direction of the difference was specified a priori.
Common Mistakes Researchers Make
Mistake 1: Using Chi-Square without checking expected cell frequencies
The most frequent error in categorical analysis. Researchers run Chi-Square by default without ever calculating expected frequencies then the test returns an invalid p-value that may appear significant even when Fisher's Exact would not be.
Mistake 2: Confusing observed and expected frequencies
The decision rule is based on expected frequencies, not observed ones. A cell with 2 observed events could have an expected frequency of 8 (no problem for Chi-Square), or a cell with 15 observed events could have an expected frequency of 3 (Fisher's Exact required). These are different numbers.
Mistake 3: Using Chi-Square or Fisher's Exact for paired data
Both Chi-Square and Fisher's Exact Test require independent observations. If the same patient appears in both rows (e.g., comparing a positive test result before and after treatment in the same patients), neither test is appropriate. Using them on paired data produces incorrect results.
Mistake 4: Applying Yates' continuity correction and then comparing with uncorrected Chi-Square
Some researchers apply Yates' continuity correction to their 2-2 Chi-Square then compare the p-value to one without correction from a reference study. The corrected test is systematically more conservative, making direct p-value comparisons invalid.
Mistake 5: Reporting only "Chi-Square, p = 0.03" without effect size
A significant Chi-Square p-value without an accompanying effect size measure gives the reader no information about the strength of the association. This omission is now a grounds for rejection in most high-impact journals.
Mistake 6: Collapsing table categories post hoc to rescue a Chi-Square with small expected frequencies
Merging categories to increase expected cell counts after seeing your data is a form of post-hoc data manipulation that inflates Type I error and must be declared in any honest methods section. If discovered in peer review, it will require reanalysis or rejection.
How to Report Results Correctly
Clear, complete reporting of categorical test results is a requirement at every stage thesis, conference abstract, or peer-reviewed publication. The following formats reflect APA 7th edition and CONSORT-aligned reporting standards.
Frequently Asked Questions
Final Summary
The choice between Chi-Square and Fisher's Exact Test is determined by one rule: calculate the expected frequency for every cell in your contingency table. If all expected frequencies are 5 or above, Chi-Square is valid and appropriate. If any expected frequency falls below 5 or if your total sample size is below 20 use Fisher's Exact Test.
Both tests answer the same question: is there a statistically significant association between two categorical variables? The difference is that Chi-Square relies on an approximation that requires sufficient data to be accurate, while Fisher's Exact Test calculates the probability directly and precisely for any sample size.
Neither test should be reported with the p-value alone. Always accompany your result with the Odds Ratio and 95% confidence interval, and the phi coefficient or Cram(c)r's V as an effect size measure. Document your expected frequency check in your methods section this is not optional, and peer reviewers will look for it. For paired binary data (same subject measured twice), use McNemar's test, not Chi-Square or Fisher's Exact.
Need help choosing the correct statistical test?
Try StatClinic AI Statistical Assistant run Chi-Square, Fisher's Exact, and McNemar tests instantly. Get APA-formatted output with effect sizes, Odds Ratios, and a written interpretation ready for your thesis or paper.
Analyze My Study