Introduction to Statistics · Chapter 3 · Probability Topics

Contingency Tables

Sort one sample by two variables at once, and read every probability in this chapter — P(A)P(A), P(A AND B)P(A \text{ AND } B), P(A OR B)P(A \text{ OR } B), P(AB)P(A \mid B) — straight off the counts.


bookSHelf  ·  Introduction to Statistics  ·  §3.4  ·  a self-paced section

Contingency Tables · bookSHelf Intro Stats§3.4

Learning objectives — by the end of this section you will be able to

Objectives

  1. Read a contingency table, and identify its joint counts, marginal totals, and grand total §3.4.1
  2. Compute P(A)P(A), P(A AND B)P(A \text{ AND } B), P(A OR B)P(A \text{ OR } B), and P(AB)P(A \mid B) directly from table counts §3.4.1
  3. Explain why a conditional probability uses a row or column total, not the grand total, as its denominator §3.4.1
  4. Fill in a partially completed table using the fact that rows, columns, and totals must agree §3.4.2
  5. Test whether two events are independent by comparing P(A AND B)P(A \text{ AND } B) against P(A)P(B)P(A)P(B) §3.4.2
  6. Read a probability contingency table, whose entries sum to 1 rather than a sample size §3.4.3
3.4

§3.4.1 — one sample, two variables, one table

A contingency table displays a sample classified by two variables at once. Every probability in this section — a single event, an AND, an OR, a conditional — is just a different region of the same table, divided by a different total.

Which total you divide by is the entire game.

Contingency Tables · bookSHelf Intro Stats§3.4

§3.4.1 — a display of a sample, two variables at once

Contingency Table

Definition 3.4.1 — Contingency Table

A contingency table displays the members of a sample classified simultaneously by two variables. Each row is one value of the first variable, each column one value of the second, and the entry where a row meets a column reports how many sample members have both of those values.

Figure: one sample partitioned by two variables at once — the interior counts are what falls out.

The two variables may be contingent on one another. A table of one variable shows how a sample splits; a contingency table shows whether that split changes depending on where you are in the other variable — exactly the question independence asks.

Contingency Tables · bookSHelf Intro Stats§3.4

§3.4.1 — three kinds of number, one table

Joint Counts, Marginal Totals, and the Grand Total

Definition 3.4.2 — Joint Count, Marginal Total, Grand Total

Joint count — an interior cell: one row and one column at once.
Marginal total — a row total or column total, regardless of the other variable.
Grand total — the whole sample, in the lower-right corner; it equals both the sum of the row totals and the sum of the column totals.

Figure: the same table, three regions, three different denominators.

Contingency Tables · bookSHelf Intro Stats§3.4

§3.4.1 — the only ingredients any probability here needs

Which total goes in the denominator?

QuestionNumeratorDenominator
P(A)P(A)marginal total for AAgrand total
P(A AND B)P(A \text{ AND } B)joint count where AA's row meets BB's columngrand total
P(A OR B)P(A \text{ OR } B)the two margins, minus the joint count oncegrand total
P(AB)P(A \mid B)joint countBB's marginal total

A grand total means "out of everybody"; a row or column total means "out of this group only."

Contingency Tables · bookSHelf Intro Stats§3.4

Insight Note — the denominator tells you which question you answered

Read your own denominator back to yourself.

Every one of the four probabilities can use the same interior cell as its numerator — what distinguishes them is the bottom of the fraction. If you ever lose track of which probability you are computing, that is the tell.

Contingency Tables · bookSHelf Intro Stats§3.4

Context Pause — why "given" shrinks the world

Once they are standing, you stop looking at the seated crowd.

Ask a lecture hall of 755 people who got a speeding ticket to stand, then ask how many of them use a phone while driving — the 755 is gone, replaced by the standing count. In a table it is literally the act of covering the rest with your hand and reading one row.

Contingency Tables · bookSHelf Intro Stats§3.4

Your turn — read a marginal and a conditional off one table

Try It Now 3.4.1

Try It Now 3.4.1 — Table 3.4.1, stretching and injuries (800 athletes)

InjuryNo injuryTotal
Stretches55295350
Does not stretch231219450
Total286514800

a. P(stretches)P(\text{stretches})?   b. P(stretchesno injury)P(\text{stretches} \mid \text{no injury})?

a. 350800=0.4375\frac{350}{800} = 0.4375   b. 2955140.5739\frac{295}{514} \approx 0.5739

Part b restricts to the 514-athlete column — the numerator 295 and denominator 514 both come from that column; the 800 never appears.

Contingency Tables · bookSHelf Intro Stats§3.4

Worked example — six probabilities, one table

Example 3.4.1 · Speeding Violations and Cell Phone Use

Speeding violationNo violationTotal
Uses cell phone25280305
Does not use cell phone45405450
Total70685755

Table 3.4.2: cell phone use against speeding violations, 755 drivers. 305+450=755305+450=755 and 70+685=75570+685=755 — the two marginal breakdowns of the same sample must agree.

a. cell phone user   b. no violation   c. no violation AND cell phone user   d. cell phone user OR no violation   e. cell phone user given a violation   f. no violation given not a cell phone user

Contingency Tables · bookSHelf Intro Stats§3.4

Example 3.4.1 — one table, six different denominators

Reading all six off Table 3.4.2

PartQuestionAnswer
acell phone user305755\frac{305}{755}
bno violation685755\frac{685}{755}
cno violation AND cell phone user280755\frac{280}{755}
dcell phone user OR no violation710755\frac{710}{755}
ecell phone user \mid violation2570\frac{25}{70}
fno violation \mid not cell phone user405450\frac{405}{450}

Parts e and f are conditionals — their denominators (70 and 450) are column and row totals, never the grand total of 755.

3.4

§3.4.2 — when a table has holes, and when two events don't care about each other

A contingency table is heavily constrained: every row sums to its row total, every column to its column total, and both sets of totals to the same grand total. Once complete, its counts already contain everything the independence test needs.

Independence is an exact statement — "close" is not "equal."

Contingency Tables · bookSHelf Intro Stats§3.4

§3.4.2 — a height comparison

The Independence Test in a Contingency Table

Definition 3.4.3 — Independence Test

Two events AA and BB in a contingency table are independent exactly when

P(A AND B)=P(A)P(B)P(A \text{ AND } B) = P(A)\,P(B)

Figure: the joint probability, measured against the product of the margins.

The table's own constraints double as a check: if it arrives with holes, the row/column/grand totals fill them for you before you compute a single probability.

Contingency Tables · bookSHelf Intro Stats§3.4

§3.4.2 — the two tests always agree

Two ways to run the same test

Joint vs. product

Read the joint count over the grand total on the left; the two marginal totals over the grand total on the right. If the two sides match, the events are independent.

Conditional vs. marginal

Equivalently, compare P(AB)P(A \mid B) with P(A)P(A): independence says conditioning on BB leaves AA's probability alone. Use whichever numbers the table hands you more cheaply.

Contingency Tables · bookSHelf Intro Stats§3.4

Insight Note — compute both sides fully before you judge

Close is not equal.

The two sides of the independence test are often close — 0.18 against 0.153 in a worked example ahead — and independence is an exact statement about the population, with no tolerance band. Carry your arithmetic far enough that a real difference cannot hide in a rounding.

Contingency Tables · bookSHelf Intro Stats§3.4

Your turn — a conditional, then the independence test

Try It Now 3.4.2

Try It Now 3.4.2 — Table 3.4.3, route preference by age (200 cyclists)

AgeLakeHillyWoodedTotal
Younger453827110
Older26521290
Total719039200

a. P(hillyolder)P(\text{hilly} \mid \text{older})?   b. Are "older" and "hilly" independent?

a. 52900.5778\frac{52}{90} \approx 0.5778   b. not independent

P(O AND H)=0.26P(O \text{ AND } H) = 0.26 but P(O)P(H)=(0.45)(0.45)=0.2025P(O)P(H) = (0.45)(0.45) = 0.20250.260.20250.26 \ne 0.2025.

Contingency Tables · bookSHelf Intro Stats§3.4

Worked example — complete a table, then test independence

Example 3.4.2 · Hiking Area Preference

SexCoastlineLakes/StreamsMtn. PeaksTotal
Women181645
Men1455
Total41

Table 3.4.4: hiking area preference, 100 hikers, partially completed.

a. complete the table   b. are "woman" and "coastline" independent?   c. P(manlakes/streams)P(\text{man} \mid \text{lakes/streams})?   d. P(woman OR mountain peaks)P(\text{woman OR mountain peaks})?

Contingency Tables · bookSHelf Intro Stats§3.4

Example 3.4.2 — let the totals close the gaps

One constraint at a time

SexCoastlineLakes/StreamsMtn. PeaksTotal
Women18161145
Men16251455
Total344125100

Table 3.4.5: 4534=1145-34=11; 4116=2541-16=25; 5539=1655-39=16 — each new entry checked against the next constraint, closing at 34+41+25=10034+41+25=100.

Contingency Tables · bookSHelf Intro Stats§3.4

Example 3.4.2 — three questions off the completed table

Independence, a conditional, and an OR

b. Not independent

P(F AND C)=0.18P(F \text{ AND } C) = 0.18
P(F)P(C)=(0.45)(0.34)=0.153P(F)P(C) = (0.45)(0.34) = 0.153
0.180.1530.18 \ne 0.153

c. and d.

P(ML)=2541P(M \mid L) = \frac{25}{41} — sample space is the 41 lakes/streams hikers, not all 100.
P(F OR P)=45+2511100=59100P(F \text{ OR } P) = \frac{45+25-11}{100} = \frac{59}{100}

Contingency Tables · bookSHelf Intro Stats§3.4

Try it in rāSHio

Let the tool build the counterfactual

Open Calculators → Probability, switch to Conditional, and enter Table 3.4.5's margins — P(F)=0.45P(F)=0.45 and P(C)=0.34P(C)=0.34 — with Assume independence ticked.

The panel returns P(F AND C)=0.153P(F \text{ AND } C) = 0.153, because ticking that box is exactly the assumption that makes the AND equal the product. That is not the answer — it is the number the table's real 0.18 gets measured against.

Contingency Tables · bookSHelf Intro Stats§3.4

Figure 3.4.1 — Calculators → Probability, Conditional mode

Building the counterfactual AND in rāSHio

Figure 3.4.1: with Assume independence ticked, rāSHio returns the AND as the product of the margins — the number the independence test compares the table's own joint probability against.

3.4

§3.4.3 — the same table, holding probabilities instead of counts

Counts are not the only thing a contingency table can hold. In many applied problems probabilities are what you are handed directly, and every rule from the count version carries over unchanged.

Only the grand total is different — it becomes 1.

Contingency Tables · bookSHelf Intro Stats§3.4

§3.4.3 — entries that tile the unit interval

Probability Contingency Table

Definition 3.4.4 — Probability Contingency Table

A probability contingency table is a contingency table whose interior entries are joint probabilities P(row AND column)P(\text{row AND column}) rather than counts. Its margins are the marginal probabilities P(row)P(\text{row}) and P(column)P(\text{column}), and its lower-right corner is 1 rather than a sample size.

Figure: the six interior entries tile the unit interval exactly — that is why the corner is 1.

P(AB)P(A \mid B) is still an interior entry divided by a margin — just an entry and a margin made of probabilities instead of counts.

Contingency Tables · bookSHelf Intro Stats§3.4

Context Pause — the corner is the check digit

The corner must be exactly 1.

Every member of the sample space is in exactly one interior cell, so a probability table's lower-right corner is always 1. If your entries do not sum to 1, find the arithmetic error before computing anything else — the cheapest check in the section.

Contingency Tables · bookSHelf Intro Stats§3.4

Your turn — mutually exclusive events, read from the problem

Try It Now 3.4.3

Try It Now 3.4.3 — Andi buys one car

Andi can afford only one of car A or car B. P(A)=0.35P(A) = 0.35, P(B)=0.65P(B) = 0.65. Find a. P(A AND B)P(A \text{ AND } B); b. P(A OR B)P(A \text{ OR } B).

a. 0   b. 1.00

"Only one car" means no overlap: P(A AND B)=0P(A \text{ AND } B)=0, so P(A OR B)=0.35+0.650=1.00P(A \text{ OR } B) = 0.35+0.65-0=1.00 — Andi buys one of the two with certainty.

Contingency Tables · bookSHelf Intro Stats§3.4

Worked example — a probability table built from the multiplication rule

Example 3.4.3 · Muddy Mouse and Three Doors

Door OneDoor TwoDoor ThreeTotal
Caught115\frac{1}{15}112\frac{1}{12}16\frac{1}{6}
Not Caught415\frac{4}{15}312\frac{3}{12}16\frac{1}{6}
Total1

Table 3.4.6: each door is chosen with probability 13\frac13; each entry is a multiplication-rule product, e.g. 115=(15)(13)\frac{1}{15}=(\frac15)(\frac13) is P(Door One AND Caught)P(\text{Door One AND Caught}).

a. complete the table, verify the corner is 1   b. P(not caught)P(\text{not caught})?   c. P(Door One OR Door Twocaught)P(\text{Door One OR Door Two} \mid \text{caught})?

Contingency Tables · bookSHelf Intro Stats§3.4

Example 3.4.3 — every column totals 13\frac13, a built-in check

Completed, and the corner checks out

Door OneDoor TwoDoor ThreeTotal
Caught115\frac{1}{15}112\frac{1}{12}16\frac{1}{6}1960\frac{19}{60}
Not Caught415\frac{4}{15}14\frac{1}{4}16\frac{1}{6}4160\frac{41}{60}
Total13\frac1313\frac1313\frac131

b. P(not caught)=4160P(\text{not caught}) = \frac{41}{60}. c. Restricted to the 1960\frac{19}{60} caught margin, Doors One and Two contribute 115+112=960\frac{1}{15}+\frac{1}{12} = \frac{9}{60}, so P(Door One OR Twocaught)=919P(\text{Door One OR Two} \mid \text{caught}) = \frac{9}{19}.

3.4

§3.4.4 — the entries only had to be additive

Nothing in the machinery of this section required headcounts. Crime rates per 100,000 inhabitants, dollar amounts, hours logged, tonnes shipped — anything you can sum across a row or column and still have it mean something works the same way.

The arithmetic is identical; the sentence you write to interpret it is not.

Contingency Tables · bookSHelf Intro Stats§3.4

Insight Note — read the units before you read the numbers

4,520.7 is not 4,520 people.

It is the sum of four years of crime rates per 100,000 inhabitants. The arithmetic for "P(Year 2 AND Robbery)P(\text{Year 2 AND Robbery})" is identical to the count case, but say "share of the total rate," not "chance that a person."

Contingency Tables · bookSHelf Intro Stats§3.4

Your turn — weight and height, seven parts

Try It Now 3.4.4

Weight / HeightTallMediumShortTotal
Overweight182814
Typical205128
Underweight12259
Total

Table 3.4.8: weight category by height category, totals omitted.

a. totals   b. P(tall)P(\text{tall})   c. P(overweight AND tall)P(\text{overweight AND tall})   d. P(talloverweight)P(\text{tall}\mid\text{overweight})   e. P(overweighttall)P(\text{overweight}\mid\text{tall})   f. P(tall AND underweight)P(\text{tall AND underweight})   g. independent?

Contingency Tables · bookSHelf Intro Stats§3.4

Try It Now 3.4.4 — same cell, different question, different answer

Completed, and the seven answers

W/HTallMed.ShortTot.
Over18281460
Typ.20512899
Under1225946
Total5010451205

b. 502050.2439\frac{50}{205}\approx0.2439
c. 182050.0878\frac{18}{205}\approx0.0878
d. 1860=0.3\frac{18}{60}=0.3
e. 1850=0.36\frac{18}{50}=0.36
f. 122050.0585\frac{12}{205}\approx0.0585
g. not independent: 0.0878(0.2927)(0.2439)0.07140.0878 \ne (0.2927)(0.2439)\approx0.0714

Contingency Tables · bookSHelf Intro Stats§3.4

Worked example — a table of rates, not headcounts

Example 3.4.4 · A Crime Index Table

YearRobberyBurglaryVandalismVehicleTotal
1145.7732.129.7314.7
2133.1717.729.1259.2
3119.3701.027.7239.1
4113.7702.226.8229.6
Total4,520.7

Table 3.4.10: crimes per 100,000 inhabitants, totals omitted; the grand total is given.

a. P(Year 2 AND Robbery)P(\text{Year 2 AND Robbery})   b. P(Year 3 AND Burglary)P(\text{Year 3 AND Burglary})   c. P(Year 3 OR Burglary)P(\text{Year 3 OR Burglary})   d. P(Year 4Vandalism)P(\text{Year 4}\mid\text{Vandalism})   e. P(VehicleYear 1)P(\text{Vehicle}\mid\text{Year 1})

Contingency Tables · bookSHelf Intro Stats§3.4

Example 3.4.4 — total once, then every part is a lookup

Totalled, and the five answers

YrRob.Burg.Van.Veh.Tot.
1145.7732.129.7314.71,222.2
2133.1717.729.1259.21,139.1
3119.3701.027.7239.11,087.1
4113.7702.226.8229.61,072.3
Tot.511.82,853.0113.31,042.64,520.7

a. 133.14520.70.0294\frac{133.1}{4520.7}\approx0.0294
b. 701.04520.70.1551\frac{701.0}{4520.7}\approx0.1551
c. 1087.1+2853.0701.04520.70.7165\frac{1087.1+2853.0-701.0}{4520.7}\approx0.7165
d. 26.8113.30.2365\frac{26.8}{113.3}\approx0.2365
e. 314.71222.20.2575\frac{314.7}{1222.2}\approx0.2575

Contingency Tables · bookSHelf Intro Stats§3.4

Key Terminology — the five terms this section defined

The vocabulary

The table itself

contingency table — a display of a sample classified by two variables at once, with rows for one, columns for the other, and counts in the interior cells.
probability contingency table — the same display, holding joint probabilities instead of counts, so its grand total is 1.

Its three regions

joint count — an interior cell; one row and one column at once.
marginal total — a row total or column total, regardless of the other variable.
grand total — the lower-right entry; the whole sample, equal to both sums of margins.

3.4

The headline result of §3.4

Independence is a height comparison, not a vibe.

P(A AND B)=P(A)P(B)P(A \text{ AND } B) = P(A)\,P(B)

Read the joint count and the two margins off the same table, divide each by the grand total, and compare. Every probability in this section — single, AND, OR, conditional — was already sitting in the table; only the denominator changed.

Equivalently, P(AB)=P(A)P(A \mid B) = P(A) — conditioning on BB leaves AA untouched exactly when the two tests agree, which they always do.

3.4
Contingency Tables · bookSHelf Intro Stats§3.4

§3.4 — conclusions

What §3.4 leaves you with

The core idea

A contingency table is one sample split by two variables. Every probability you need is a region of that table — a joint count, a marginal total, or the grand total — divided by whichever total the question names.

The failure case

A joint probability close to the product of the margins is still dependence, not independence — 0.18 against 0.153 in Example 3.4.2. There is no tolerance band; compute both sides fully before you judge.

Next: §3.5 — Tree and Venn Diagrams, two more ways to picture the same probabilities.