[Durgical](https://durgical.com/en/) › [DurgiPedia](https://durgical.com/en/durgipedia/) › [Epidemiology](https://durgical.com/en/epidemiology/) › [Biostatistics](https://durgical.com/en/epidemiology/areas/stats/) › Chi-square test

# Chi-square test

- Statistical test

It compares proportions between groups by measuring how far the observed counts are from those expected if there were no association.

Updated Nov 5, 2026

## Key points

- Expected count of a cell = (its row total × its column total) / grand total.
- χ² = Σ (observed − expected)² / expected.
- Degrees of freedom = (rows − 1) × (columns − 1); in a 2 × 2 table df = 1 and the critical value at α = 0.05 is 3.84.
- Usual requirement: all expected counts ≥ 5 (or at least 80% ≥ 5 and none

## What it is

The chi-square (χ²) test of independence assesses whether two categorical variables are associated in a contingency table, for example exposure (yes/no) and disease (yes/no). For each cell it calculates the count expected if there were no association and adds up the squared differences between observed and expected, divided by expected. With small expected counts it becomes unreliable and the Fisher exact test is used.

## When to use it

- Proportions in two or more independent groups (r × c table).
- Goodness of fit: whether an observed distribution matches an expected one.
- Fisher exact test: 2 × 2 tables with any expected count below 5.

## Worked example

- Data: after a lunch, of 50 people who ate the salad 30 fell ill; of 50 who did not, 10 fell ill.
- Totals: 40 ill and 60 well out of 100 people.
- Expected per row: ill = 50 × 40 / 100 = 20; well = 50 × 60 / 100 = 30 (the same in both rows).
- Ate: (30 − 20)² / 20 = 5.0 and (20 − 30)² / 30 = 3.33.
- Did not eat: (10 − 20)² / 20 = 5.0 and (40 − 30)² / 30 = 3.33.
- χ² = 5.0 + 3.33 + 5.0 + 3.33 = 16.7 with 1 df. It exceeds 3.84; p

| Exposure | Ill | Well | Total |
| --- | --- | --- | --- |
| Ate the salad | 30 (20) | 20 (30) | 50 |
| Did not eat it | 10 (20) | 40 (30) | 50 |
| Total | 40 | 60 | 100 |

## Markers

- χ²
- df
- Fisher

## Assumptions and pitfalls

- Using it with expected counts below 5 (use Fisher).
- Using it on paired data (use McNemar).
- Calculating it from percentages instead of absolute counts.
- Reading a large χ² as a strong association: it also grows with sample size.

## Memory aid

‘What is there against what would be’: χ² adds up how far the observed counts sit from those expected with no association.

## Test yourself

Think of the answer, then tap the question to see it.

## How is the expected count of a cell calculated?

Multiply its row total by its column total and divide by the grand total.

## How many degrees of freedom does a 3 × 4 table have?

(3 − 1) × (4 − 1) = 6.

## When is the Fisher exact test preferred?

When any expected count in a 2 × 2 table is below 5.

## What limits χ² as a measure of the strength of an association?

Its value grows with sample size; strength is reported with the RR or OR and its confidence interval.

[Add to my cards (4)](https://durgical.app/estudiar/?add=/en/epidemiology/chi-square-test/)

## Connections

## Related 5

- [The 2×2 table](https://durgical.com/en/epidemiology/the-2-2-table/)
- [McNemar test](https://durgical.com/en/epidemiology/mcnemar-test/)
- [Choosing a statistical test](https://durgical.com/en/epidemiology/choosing-a-statistical-test/)
- [Relative risk](https://durgical.com/en/epidemiology/relative-risk/)
- [Attack rate](https://durgical.com/en/epidemiology/attack-rate/)

[← All of epidemiology](https://durgical.com/en/epidemiology/)

Educational content on epidemiological and statistical methods; the examples use made-up numbers to teach the calculation. Not a clinical or legal guide: current Colombian rules are in the official sources.

Sources: [How can we compare the results of classifying according to several categories?](https://www.itl.nist.gov/div898/handbook/prc/section4/prc45.htm) (NIST/SEMATECH e-Handbook of Statistical Methods, National Institute of Standards and Technology, 2012); [Principles of Epidemiology | Lesson 3 - Section 5](https://archive.cdc.gov/www_cdc_gov/csels/dsepd/ss1978/lesson3/section5.html) (Centers for Disease Control and Prevention, 2012); [What are statistical tests?](https://www.itl.nist.gov/div898/handbook/prc/section1/prc13.htm) (NIST/SEMATECH e-Handbook of Statistical Methods, National Institute of Standards and Technology, 2012).

## **Spotted a mistake?** We are always improving for the community. Tell us what is wrong and our team will review it. Report a mistake

Representative model, for educational purposes only.

---
Source: https://durgical.com/en/epidemiology/chi-square-test/
License: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Cite as: DurgiPedia (durgical.com), https://durgical.com/en/epidemiology/chi-square-test/
