Idea
The chi-square test compares observed counts to expected counts under independence.
Rule-of-thumb: expected counts should usually be ≥ 5 in most cells; otherwise consider Fisher's exact test for 2×2 tables.
Interactive 2×2 chi-square (teaching demo)
Enter a 2×2 table (e.g., treatment vs outcome) and see observed vs expected.
Observed vs expected
Big gaps between observed and expected contribute to χ².
Real Dental Scenario
Is Smoking Associated with Periodontal Disease?
The study: A periodontist examined 300 patients and recorded their smoking status and whether they had periodontal disease. Is there an association between smoking and periodontal disease?
Observed Data (Contingency Table)
| Periodontal Disease (Yes) | Periodontal Disease (No) | Row Total | |
|---|---|---|---|
| Smoker | 45 | 30 | 75 |
| Non-Smoker | 55 | 170 | 225 |
| Column Total | 100 | 200 | 300 |
Step 1: Calculate Expected Values
E = (Row Total × Column Total) / Grand Total
(75 × 100) / 300 = 25.00
(75 × 200) / 300 = 50.00
(225 × 100) / 300 = 75.00
(225 × 200) / 300 = 150.00
Step 2: Compute (O − E)² / E for Each Cell
(45 − 25)² / 25 = 400/25 = 16.000
(30 − 50)² / 50 = 400/50 = 8.000
(55 − 75)² / 75 = 400/75 = 5.333
(170 − 150)² / 150 = 400/150 = 2.667
Step 3: Sum & Make a Decision
Significant Association Found!
χ²(1) = 32.00, p < 0.0001
There is a highly significant association between smoking status and periodontal disease. Smokers are substantially more likely to have periodontal disease than non-smokers (60% vs 24.4%).
Dental use
Use chi-square for associations like "smoker vs non-smoker" and "periodontitis yes/no," or "device positive/negative" across groups. Always report the table, effect size (e.g., risk ratio/odds ratio), and CI if possible.