Statistics › Section C · Probability › Topic C.4

Contingency tables

Cross-classify two categorical variables and every probability question from this chapter - joint, marginal, conditional, or, independence - becomes a division you can see. This topic reads two-way tables systematically.

Two variables, one table

When a study records two categorical variables for each person - studies French or not, plays in a band or not - the counts cross-classified by both land in a contingency table, also called a two-way table. Its power is that every probability question from the previous topics - joint, marginal, conditional, or, independence - becomes a visible division. This topic reads tables systematically, and every check is arithmetic you can do in the margins.

Anatomy of a contingency table

Take the survey of 200 students from the previous topics, cross-classified: French and band, 24; French only, 56; band only, 36; neither, 84. The body cells hold the joint counts; the margins hold the row totals (French 80, no French 120) and column totals (band 60, no band 140); the grand total is 200. Before using any table, verify it: each row's cells must add to that row's total, and the row totals and the column totals must each add to the grand total. Here \(80 + 120 = 200\) and \(60 + 140 = 200\), so the table closes.

Joint and marginal probabilities

A cell divided by the grand total is a joint probability: \(P(\text{French and band}) = \frac{24}{200} = 0.12\). A margin divided by the grand total is a marginal probability - one variable alone: \(P(\text{French}) = \frac{80}{200} = 0.40\) and \(P(\text{band}) = \frac{60}{200} = 0.30\). Marginals ignore the other variable entirely; joints require both. Both share the same denominator, 200, which is what keeps the two kinds of number comparable.

Conditional probabilities from a table

A conditional probability restricts the world to one row or column: divide a cell by its row or column total, not the grand total. \(P(\text{band} \mid \text{French}) = \frac{24}{80} = 0.30\): among the 80 French students, 30% play in a band. \(P(\text{French} \mid \text{band}) = \frac{24}{60} = 0.40\): among the 60 band members, 40% study French. The two conditionals share a numerator but not a denominator - 80 versus 60 - so they are different questions with different answers.

AND and OR from cells

The table makes and/or questions visual. AND is one cell: \(P(\text{French and band}) = \frac{24}{200}\). OR is three cells - French only, band only, and both: \(\frac{56+36+24}{200} = \frac{116}{200} = 0.58\), matching the addition rule's \(0.40 + 0.30 - 0.12\). The neither-cell shortcut is often faster: \(P(\text{or}) = 1 - P(\text{neither}) = 1 - \frac{84}{200} = 0.58\). Three routes, one answer - which is exactly how table work should check itself.

Testing independence with a table

Independence has two equivalent tests, and a table answers both. Compare conditionals: \(P(\text{band} \mid \text{French}) = 0.30\) equals \(P(\text{band}) = 0.30\), so knowing a student studies French leaves band membership unchanged - the events are independent. Or compare products: \(P(\text{French}) \times P(\text{band}) = 0.40 \times 0.30 = 0.12\), which equals the joint cell probability \(\frac{24}{200}\). If conditionals differ from marginals, the variables are associated: one carries information about the other.

Worked example: the warranty table

An electronics store surveys 300 buyers: warranty and under 40, 42; no warranty and under 40, 108; warranty and 40 or older, 66; no warranty and 40 or older, 84. 1. Verify margins: under 40, \(42+108 = 150\); 40 or older, \(66+84 = 150\); warranty, \(42+66 = 108\); no warranty, \(108+84 = 192\); and \(108 + 192 = 300\). 2. \(P(\text{warranty}) = \frac{108}{300} = 0.36\). 3. \(P(\text{warranty} \mid \text{under 40}) = \frac{42}{150} = 0.28\). 4. \(P(\text{warranty} \mid 40+) = \frac{66}{150} = 0.44\). 5. The three numbers differ, so age and warranty choice are associated: older buyers buy the warranty more often. Check: \(P(\text{under 40 and warranty}) = \frac{42}{300} = 0.14\) against \(P(\text{under 40})P(\text{warranty}) = 0.50 \times 0.36 = 0.18\); the mismatch confirms dependence.

Worked example: the two directions, carefully

From the same table: among warranty buyers, what share are 40 or older? \(P(40+ \mid \text{warranty}) = \frac{66}{108} \approx 0.61\). And among buyers 40 or older, what share bought the warranty? \(P(\text{warranty} \mid 40+) = \frac{66}{150} = 0.44\). Same cell, different denominators, different numbers: 61% of warranty buyers are older, while 44% of older buyers took the warranty. Confusing the directions is the table-reader's version of the \(P(A \mid B)\) versus \(P(B \mid A)\) swap. Check each: the first divides by 108, the warranty column; the second by 150, the 40+ row.

Tables of proportions

Contingency tables sometimes carry percentages instead of raw counts - survey reports and poll cross-tabs often do. The readings barely change: with a table of proportions summing to 1, the cells are already joint probabilities and the margins are already marginals, so only conditionals still need a division, by the row or column margin. The warranty table stated as percentages of 300 buyers would show 14% (warranty and under 40), 36% margin for warranty and 50% for under 40 - exactly the numbers computed above. Counts and proportions tell the same story; always check which one a published table is showing, because dividing a percentage by a headcount produces nonsense.

Common mistakes to avoid

First, dividing a cell by the grand total when the question is conditional: the denominator is the row or column total of the given event. Second, swapping the two conditional directions - 61% versus 44% above. Third, reading a marginal as if it were conditional: \(P(\text{warranty}) = 0.36\) describes all buyers, not the under-40s alone. Fourth, declaring independence without running one of the two tests. Fifth, using a table whose margins do not close - disagreeing totals mean a miscount somewhere. Sixth, treating an association found in one sample as proof of a causal link.

Key takeaways

A contingency table cross-classifies two categorical variables into joint cells, with row and column margins and one grand total. Cells over the grand total give joint probabilities; margins over the grand total give marginals; cells over their row or column totals give conditionals. AND reads one cell; OR reads three cells, or the complement of the neither-cell. Independence holds exactly when every conditional equals its matching marginal - equivalently, when \(P(A)P(B)\) equals the joint cell probability. And the two conditional directions are different questions with different denominators: 0.61 is not 0.44.

Flashcards

Flashcard

Contingency table

Counts cross-classified by two categorical variables

Also called a two-way table.

Test your understanding

Question 1 of 5

The warranty table of 300 buyers: under 40, 42 warranty and 108 none; 40 or older, 66 warranty and 84 none. What is P(no warranty and 40 or older)?

Question 2 of 5

In the same warranty table, 192 buyers took no warranty, 108 of them under 40. What is P(under 40 | no warranty), to two decimal places?

Question 3 of 5

In the warranty table, 150 of the 300 buyers are under 40. What is P(under 40)?

Question 4 of 5

P(warranty | under 40) = 0.28 while P(warranty) = 0.36. The two variables are:

Question 5 of 5

In the warranty table, P(under 40) = 0.50, P(warranty) = 0.36 and P(warranty and under 40) = 0.14. What is P(under 40 or warranty)?

← Previous topicNext topic →