---
tag: PANSMHE0SW
kind: concept
name: Contingency table
msc: [62H17]
sources:
  - url: https://en.wikipedia.org/wiki/Contingency_table
same_as:
  wikidata: Q1541178
  wikipedia: Contingency table
---

## Summary

A contingency table counts how many observations fall into each combination of categories of two or more categorical variables.
It is the basic form of data for studying the association between categorical variables.
The chi-squared test and [[Fisher's exact test|J6JP5CJNPX]] test independence of the variables from such a table.
Larger tables are analysed with log-linear models.

## Explanations

### L1 human

Ask $100$ people whether they smoke and whether they exercise.
Write the answers in a table with two rows, smoker and non-smoker, and two columns, exercises and does not.
Each cell holds the number of people with that pair of answers, and the four numbers add up to $100$.
Comparing the rows shows whether smoking and exercise seem related.
