Two-Way Tables

Two yes-or-no questions, four boxes, and a set of totals that must agree. Then turn counts into percentages.

Ask sixty people two yes-or-no questions: do you own a dog? do you own a cat?

Every single person lands in exactly one of four groups. Nobody is in two, nobody is in none.

sixty people, two questions, four boxes do you own a dog? do you own a cat? dog + cat 12 dog, no cat 18 cat, no dog 20 neither 10

Count them and the four boxes hold 12, 18, 20 and 10. Those add to 60, and they must — you asked everybody once.

That is your first check. If the four counts do not reach the grand total, a box is wrong.

Now a harder question: are dog owners more likely to own a cat than non-dog-owners?

Counts alone cannot tell you, because the groups are different sizes. You have to turn them into percentages — and which total you divide by decides which question you just answered.

A two-way frequency table with row and column totals a two-way table counts every person once, in exactly one cell dogno dogtotal catno cattotal 121830 201030 322860 rows add across columns add down both reach 60 12 of the 32 dog owners also keep a cat, which is about 38 percent of them

Filling the table in

One variable labels the rows, the other labels the columns. Every person lands in exactly one inner cell.

Row totals go down the right-hand edge; column totals go along the bottom. The bottom-right corner is the grand total.

Fill in everything you are given, then use the totals to work out what is missing.

Totals are your check

Add the row totals. Add the column totals. Both must give the grand total. If they disagree, one inner cell is wrong.

Three different percentages

You can divide a cell by its row total, its column total, or the grand total. All three are legitimate, and they answer different questions.

"What percent of cat owners have a dog?" divides by the cat row total.

"What percent of dog owners have a cat?" divides by the dog column total. Different question, different answer.

Find the "of"

The words after "percent of" name the denominator. "Of the students who walk" means the walk total goes on the bottom. Underline those words before you divide.

Looking for association

If the percentage is roughly the same across the rows, the two variables are unrelated.

If it differs markedly, there is an association. 60% of one group against 25% of the other is a real difference.

Compare percentages, never raw counts — a bigger group will have bigger counts no matter what.

Counts mislead

40 out of 200 is a smaller share than 15 out of 50, even though 40 > 15. Convert to percentages before comparing.

Reading an incomplete table

Work out the easy missing entries first: any row or column with exactly one gap.

Each one you fill may open up another. Keep going round.

Finish by checking both sets of totals against the grand total.

Worked examples

Completing a table

Of 60 students, 32 walk. Of the walkers, 12 bring lunch. Altogether 27 bring lunch. Complete the table.

  1. Walk row: 12 bring lunch, so 32 - 12 = 20 do not. The row must total 32.
  2. Not-walk row total: 60 - 32 = 28 The column totals must reach 60.
  3. Lunch column: 27 total, 12 from walkers, so 15 from non-walkers. Fill the gap in the lunch column.
  4. Non-walkers with no lunch: 28 - 15 = 13 Check: 12 + 20 + 15 + 13 = 60 ✓

Walk: 12 / 20. Not walk: 15 / 13

Which denominator?

From that table, what percent of walkers bring lunch? And what percent of lunch-bringers walk?

  1. "Percent of walkers" means divide by 32. The words after "of" give the denominator.
  2. 1232 = 0.375 = 37.5% The first answer.
  3. "Percent of lunch-bringers" means divide by 27. A different denominator entirely.
  4. 1227 ≈ 44.4% Same cell, different question, different answer.

37.5% and about 44.4%

Is there an association?

12 of 32 walkers bring lunch; 15 of 28 non-walkers do. Is walking associated with bringing lunch?

  1. Walkers: 1232 = 37.5% Convert to a percentage.
  2. Non-walkers: 1528 ≈ 53.6% Same for the other group.
  3. 53.6% against 37.5% is a noticeable gap. About 16 percentage points.
  4. So yes, there is some association in this sample. Still not proof of cause.

Yes — non-walkers bring lunch more often here

Words to know

Two-way table
A table of counts sorted by two categorical variables at once.
Joint frequency
A count in a single inner cell.
Marginal frequency
A row total or a column total, out at the margin.
Relative frequency
A count expressed as a fraction or percentage of some total.

Mistakes to watch for

Dividing by the grand total when the question asked about one row. The words after "percent of" name the denominator. "Of the cat owners" means divide by the cat row total, not by 60.

Comparing raw counts between groups of different sizes. 40 out of 200 is a smaller share than 15 out of 50, even though 40 > 15. Convert to percentages first, every time.

Forgetting that both sets of totals must agree. Add the row totals and add the column totals; both must give the grand total. It is the cheapest way to catch a miscounted cell.

Reading the row variable as the column variable. Transposing the table swaps every "percent of" question for a different one — same cells, completely different answers.

A famous trap: in 1973 Berkeley appeared to admit men at a higher rate than women, and was nearly sued.

But broken down department by department, most departments favoured women. Women had simply applied more often to the departments that rejected nearly everybody.

This reversal is called Simpson's paradox, and it is the reason statisticians insist on seeing the two-way table rather than the summary.

Browse all courses