Categorical Data Analysis

Chi-square, Fisher’s, and Risk Measures

The Clinical Problem

Monsoon season — a village near Sagar, MP. 200 people attend a wedding feast. Within 48 hours, 80 develop acute gastroenteritis.

The district surveillance officer constructs a 2×2 table for biryani exposure:

Ate Biryani Did Not Total
Ill 65 15 80
Well 30 50 80
Total 95 65 160

Questions: Is biryani associated with illness? How strong is the association? What’s the clinical impact?

The 2×2 Contingency Table

The fundamental building block of categorical data analysis:

Disease No Disease Total
Exposed a b a + b
Not Exposed c d c + d
Total a + c b + d N

From this single table we can derive:

  • Tests: Chi-square, Fisher’s exact
  • Association: RR, OR
  • Impact: ARR, NNT, AR, PAR

Chi-square Test of Independence

H₀: Exposure and disease are independent (no association)

H₁: Exposure and disease are associated

In words: For each cell, take (Observed − Expected)², divide by Expected, sum across all cells.

\[\chi^2 = \sum \frac{(\text{Observed} - \text{Expected})^2}{\text{Expected}}\]

For a 2×2 table, the cross-product shortcut:

\[\chi^2 = \frac{N(ad - bc)^2}{(a+b)(c+d)(a+c)(b+d)}, \quad df = 1\]

Expected frequency: \(E_{ij} = \frac{\text{Row Total} \times \text{Column Total}}{\text{Grand Total}}\)

Worked Example: Biryani Outbreak

Reject H₀ — biryani exposure and illness are significantly associated.

When Chi-square Fails: Fisher’s Exact Test

Use Fisher’s exact test when:

  • Any expected cell frequency < 5
  • Total sample size N < 20–30
  • Rare disease or rare exposure

Example: Leptospirosis cluster after flooding in Alappuzha, Kerala (N = 25):

Leptospirosis Healthy
Waded in floodwater 8 2
Did not wade 3 12

Fisher’s p = 0.0051, OR = 13.77

McNemar’s Test: Paired Categorical Data

Same subjects, before–after → only discordant pairs matter

Example: TB knowledge in 100 contacts, Patna — before and after health education

After: Correct After: Incorrect
Before: Correct 55 5
Before: Incorrect 25 15

\[\chi^2_{\text{McNemar}} = \frac{(b - c)^2}{b + c} = \frac{(5 - 25)^2}{30} = 13.33, \quad p < 0.001\]

Knowledge significantly improved after education. The 55 + 15 concordant pairs are ignored.

Measures of Association: Overview

Measure In Words Cell Notation Use
Relative Risk (RR) Risk in Exposed ÷ Risk in Unexposed a/(a+b) ÷ c/(c+d) Cohort
Odds Ratio (OR) Odds in Exposed ÷ Odds in Unexposed ad / bc Case-control
ARR Risk in Control − Risk in Treatment Rc − Rt Trials
RRR ARR ÷ Risk in Control ARR / Rc Trials
NNT 1 ÷ ARR (treat how many to save one?) 1 / ARR Clinical
NNH 1 ÷ Absolute Risk of Harm 1 / ARH Safety
AR Risk in Exposed − Risk in Unexposed Re − Ru Individual
PAR Fraction of population disease due to exposure Pe(RR−1) / [Pe(RR−1)+1] Public health

Relative Risk (RR)

In words: Risk of disease in Exposed ÷ Risk of disease in Unexposed

\[RR = \frac{\text{Incidence in Exposed}}{\text{Incidence in Unexposed}} = \frac{a/(a+b)}{c/(c+d)}\]

Outbreak example:

  • Risk in exposed (biryani): 0.684 (68.4%)
  • Risk in unexposed: 0.231 (23.1%)
  • RR = 2.96 — biryani eaters were 3× more likely to fall ill

Key: RR can only be calculated from cohort studies where you follow exposed and unexposed groups forward.

Odds Ratio (OR)

In words: Odds of disease in Exposed ÷ Odds of disease in Unexposed

\[OR = \frac{\text{Odds in Exposed}}{\text{Odds in Unexposed}} = \frac{ad}{bc} \quad \text{(cross-product ratio)}\]

  • OR = 7.22

Why not just use RR?

In case-control studies, you cannot calculate incidence → cannot get RR → must use OR.

The critical question: When does OR ≈ RR?

OR ≈ RR: The Rare Disease Assumption

\[OR \approx RR \text{ when disease prevalence < 5–10%}\]

95% Confidence Interval for OR

\[OR_{95\%CI} = OR \times e^{\pm\, 1.96 \times SE(\ln OR)}\]

where \(SE(\ln OR) = \sqrt{1/a + 1/b + 1/c + 1/d}\)

Outbreak result: OR = 7.22 (95% CI: 3.51 – 14.86)

Interpretation rule:

  • CI includes 1.0 → not significant (p > 0.05)
  • CI excludes 1.0 → significant (p < 0.05)

ARR, RRR, and NNT

TB vaccine trial in Varanasi: Vaccinated 5/500 (1%); Unvaccinated 20/500 (4%)

ARR (how much does treatment lower absolute risk?):

\[ARR = \text{Risk in Control} - \text{Risk in Treatment} = 4\% - 1\% = 3\%\]

RRR (what fraction of baseline risk is removed?):

\[RRR = \frac{ARR}{\text{Risk in Control}} = \frac{3\%}{4\%} = 75\%\]

NNT (how many to treat to prevent one case?):

\[NNT = \frac{1}{ARR} = \frac{1}{0.03} \approx 33\]

Clinical meaning: Vaccinate 33 people to prevent one case of TB.

Warning

RRR (75%) sounds impressive; ARR (3%) gives the true clinical picture.

NNT and NNH: The Full Picture

Therapeutic index = NNH / NNT = 83 / 33 = 2.5 → Benefit outweighs harm → Recommend vaccination

Attributable Risk (AR) and Population Attributable Risk (PAR)

AR — excess risk from exposure (individual level)

\[AR = \text{Risk in Exposed} - \text{Risk in Unexposed}\]

“How much extra disease does the exposure cause?”

. . .

Smoking example:

AR = 8% − 1% = 7%

AR% = 7/8 = 87.5% of lung cancer in smokers is attributable to smoking

PAR — population-level impact (depends on both RR and exposure prevalence)

\[PAR\% = \frac{P_e(RR - 1)}{P_e(RR - 1) + 1} \times 100\]

“If we eliminated this exposure, what fraction of ALL disease would disappear?”

. . .

If 40% smoke, RR = 8:

PAR% = 73.7% of all lung cancer could be prevented by eliminating smoking

Decision Guide: Choosing the Right Test

Scenario Test / Measure
2 independent groups, expected freq ≥ 5 Chi-square test
2 independent groups, expected freq < 5 Fisher's exact test
Paired / before–after McNemar's test
Cohort study → risk measure Relative Risk (RR)
Case-control study → association measure Odds Ratio (OR)
Clinical impact of treatment ARR, RRR, NNT, NNH

Common Pitfalls

Avoid

  • Chi-square with expected freq < 5
  • Interpreting OR as RR at high prevalence
  • Claiming causation from chi-square alone
  • Forgetting to report 95% CI for OR/RR
  • Confusing ARR (absolute) with RRR (relative)

Remember

  • Fisher’s exact test for small samples
  • OR ≈ RR only when disease is rare (< 5–10%)
  • McNemar’s for paired categorical data
  • NNT = 1/ARR, not 1/RRR
  • CI excluding 1.0 → statistically significant

Key Takeaways

  1. Chi-square tests association between two categorical variables (check expected freq ≥ 5)
  2. Fisher’s exact for small samples; McNemar’s for paired before–after data
  3. RR from cohort studies; OR from case-control studies
  4. OR ≈ RR only when disease is rare (< 5–10% prevalence)
  5. ARR gives the true clinical impact; RRR can be misleading
  6. NNT = 1/ARR — lower is better; compare NNT to NNH for net benefit
  7. AR for individual counselling; PAR for public health policy
  8. Always report 95% CI — if it excludes 1.0, the result is significant