Contingency tables
A contingency table (the term was introduced by Karl Pearson in 1904) counts how many fall into each combination of two categorical variables. Rows and columns are summed to margins. Three kinds of probability can be read from the table:
- Joint probabilities: cell / total, e.g. $P(\text{male} \cap \text{died})$.
- Marginal probabilities: row or column total / total, e.g. $P(\text{died})$.
- Conditional probabilities: cell / row or column total, e.g. $P(\text{died}\,|\,\text{male})$. These are the row percentages (or column percentages).
The classic example is the Titanic, which sank on the night of 14–15 April 1912. Of the 2201 on board (passengers and crew) 711 survived. The principle “women and children first” shows clearly in the table.
Risk, odds and independence
Let $p_1$ and $p_2$ be the probability of the outcome in the two rows. Then
where $a, b, c, d$ are the four cells. If the row variable and the column variable are independent, the row percentages are equal, and each cell is expected to contain $\text{row total}\times\text{column total}/\text{total}$. The χ² test (see statistical distributions) measures the distance between the observed and the expected counts; for a 2×2 table it has 1 degree of freedom. But remember: an association in a contingency table does not prove cause. That requires a randomised trial like the vaccine trial, where only the treatment distinguishes the groups.
Venn diagrams
A Venn diagram shows the same four cells as a 2×2 table: $A \cap B$, $A \cap \bar B$, $\bar A \cap B$ and $\bar A \cap \bar B$. It is good for seeing intersections and the addition rule, but less good for conditional probabilities, because the areas of the circles are rarely drawn to scale. The page on probability has an interactive, area-true Venn diagram, and on the page on logic you can shade regions for any expression in three sets.
Tree diagrams
A tree diagram shows an experiment in several stages. Each branch carries a conditional probability, and the probability of a whole path from root to leaf is the product of the branch probabilities (the multiplication rule):
The branches from each node sum to 1, and the leaves together sum to 1. The tree naturally follows the order in which things happen: first one is ill or well, then the test turns out positive or negative. But often one wants to know the reverse – and then the tree must be turned round.
The law of total probability and Bayes’ theorem
The probability of $B$ is found by adding all the paths to $B$:
and turning the tree round is Bayes’ theorem:
It has a page of its own: Bayes’ theorem. A good rule of thumb from the psychologist Gerd Gigerenzer: calculate in natural frequencies – “out of 1000 people 10 are ill; 9 of them test positive; of the 990 healthy, 89 test positive” – and the answer $9/(9+89) \approx 9\ \%$ becomes almost self-evident. The contingency table is precisely natural frequencies.
Simpson’s paradox
An association that holds in every single subgroup can reverse when the groups are combined. The phenomenon was described by Edward Simpson in 1951 (and before him by Udny Yule in 1903). A famous example is a British study of the treatment of kidney stones (Charig et al., British Medical Journal 1986): open surgery (A) had a higher success rate than keyhole surgery (B) for both small and large stones – but a lower one overall.
Good advice
Ask: percentage of what?
Row and column percentages answer different questions. “90 % of the ill test positive” is not the same as “90 % of those testing positive are ill”.
Count before you calculate
Rewrite probabilities as numbers in an imagined group of, say, 1000 or 100,000 people. Then contingency table, tree and Bayes become simple counting.
Look for confounders
Before concluding that A leads to B, ask whether a third variable affects both. Randomisation is the surest cure.
Absolute and relative risk
“Risk halved” sounds like a lot, but from 2 in 10,000 to 1 in 10,000 is an absolute difference of 1 in 10,000. State both.
Further reading
- Gerd Gigerenzer: Reckoning with Risk – Learning to Live with Uncertainty (Penguin 2003)
- David Spiegelhalter: The Art of Statistics – Learning from Data (Pelican 2019)
- Judea Pearl and Dana Mackenzie: The Book of Why (Basic Books 2018) – on causes, confounders and Simpson’s paradox
- The pages on probability and Bayes’ theorem