Skip to content
Family Table Math
Auto

Contingency Tables

Scatter plots work when both variables are numbers. But what if both are categories, like grade level and where students eat lunch? Then you organize the data in a contingency table (two-way table) and compare percentages to see whether the two variables are related.

A contingency table counts how many individuals fall into each combination of two categorical variables. One variable labels the rows, the other labels the columns, and each cell holds a count.

Packed lunchCafeteriaOff campusTotal
Junior (Gr 9–10)686842421010120120
Senior (Gr 11–12)454535355050130130
Total11311377776060250250
  • Row totals (right column) and column totals (bottom row) are the marginal totals.
  • The bottom-right number is the grand total. Both the row totals and the column totals add up to it, which is a handy check.

A relative frequency divides a count by the grand total:

relative frequency=cell countgrand total\text{relative frequency} = \frac{\text{cell count}}{\text{grand total}}

For example, 68250=0.272\dfrac{68}{250} = 0.272, so 27.2%27.2\% of all students surveyed are juniors who pack a lunch.

To compare groups fairly when they’re different sizes, use percentages within each group.

  • Row percentage: divide each cell by its row total. Use this to compare the rows (here, juniors versus seniors).
  • Column percentage: divide each cell by its column total. Use this to compare the columns.

A row percentage is exactly a conditional probability: the percentage of seniors who eat off campus is P(off campus∣senior)P(\text{off campus} \mid \text{senior}).

If the two variables are not related, each row would have roughly the same row percentages (and they would match the overall percentages in the Total row). If the row percentages differ a lot, the data suggest a relationship. As always, a relationship doesn’t prove cause and effect (see correlation and causation).

Two-way tables are an SAT favourite, and Desmos only helps with the division. The real skill is choosing the right denominator: read the wording carefully. “Of the students who own a bike, what fraction…” uses that row’s (or column’s) total, while “what fraction of all students…” uses the grand total. Find the total you need first, then the count, and the answer is count over total. See using Desmos on the SAT.

A survey of 160160 students asked whether they keep their phone in their bedroom at night and whether they usually get at least 88 hours of sleep. Complete the table.

8 h or moreUnder 8 hTotal
Phone in bedroom22228080
No phone in bedroom3232
Total160160

Solution.

  • Phone, under 8 h: 80−22=5880 - 22 = 58.
  • No phone total: 160−80=80160 - 80 = 80, so no phone, 8 h or more: 80−32=4880 - 32 = 48.
  • Column totals: 22+48=7022 + 48 = 70 and 58+32=9058 + 32 = 90.
8 h or moreUnder 8 hTotal
Phone in bedroom222258588080
No phone in bedroom484832328080
Total70709090160160

Check: 70+90=16070 + 90 = 160. ✓

Using the lunch table above, find the relative frequency of (a) seniors who eat off campus (b) all students who eat in the cafeteria.

Solution.

(a) 50250=0.2\dfrac{50}{250} = 0.2, or 20%20\% of all students surveyed.

(b) 77250=0.308\dfrac{77}{250} = 0.308, or 30.8%30.8\%.

Example 3: Row percentages and a relationship

Section titled “Example 3: Row percentages and a relationship”

Use row percentages to compare juniors and seniors in the lunch table. Is there a relationship between grade level and where students eat lunch?

Solution. Divide each cell by its row total.

Packed lunchCafeteriaOff campus
Junior68120≈56.7%\tfrac{68}{120} \approx 56.7\%42120=35.0%\tfrac{42}{120} = 35.0\%10120≈8.3%\tfrac{10}{120} \approx 8.3\%
Senior45130≈34.6%\tfrac{45}{130} \approx 34.6\%35130≈26.9%\tfrac{35}{130} \approx 26.9\%50130≈38.5%\tfrac{50}{130} \approx 38.5\%

The patterns are very different. Only about 8%8\% of juniors eat off campus, compared with about 39%39\% of seniors, and juniors are much more likely to pack a lunch. So in this survey, grade level and lunch location appear to be related. (A possible reason: many schools let only senior students leave at lunch.)

In probability language, P(off campus∣senior)=50130≈0.385P(\text{off campus} \mid \text{senior}) = \tfrac{50}{130} \approx 0.385.

Using the lunch table, what percentage of the students who eat off campus are seniors? Why is this different from the percentage of seniors who eat off campus?

Solution. “Of the students who eat off campus” means look only at the Off campus column:

5060≈83.3%\frac{50}{60} \approx 83.3\%

The percentage of seniors who eat off campus uses the Senior row instead: 50130≈38.5%\tfrac{50}{130} \approx 38.5\%.

Same cell, different group. Ask “out of whom?” The group after “of” tells you which total to divide by.

Comparing raw counts when groups are different sizes. 4545 seniors and 6868 juniors pack a lunch, but there are more seniors overall. Compare percentages, not counts.

Dividing by the wrong total. Relative frequency uses the grand total, row percentage uses the row total, and column percentage uses the column total. Decide which group the question is about first.

Mixing up “percentage of seniors who…” with “percentage of … who are seniors”. These are different, just like P(A∣B)P(A \mid B) and P(B∣A)P(B \mid A).

Forgetting to check totals. Row totals and column totals must both add up to the grand total. If they don’t, there’s an arithmetic error somewhere.

Calling a relationship “cause and effect”. A contingency table can show that two variables are related, not why.

1. (Warm-up) Using the completed table in Example 1, how many students surveyed get under 88 hours of sleep? How many keep their phone in their bedroom?

Solution

9090 get under 88 hours; 8080 keep their phone in their bedroom.

2. (Warm-up) Using Example 1, find the relative frequency of students who keep their phone in their bedroom and get 88 hours or more.

Solution

22160=0.1375≈0.138\dfrac{22}{160} = 0.1375 \approx 0.138, or about 13.8%13.8\%.

3. (Warm-up) To answer “What percentage of Grade 12 students play a sport?”, where grade labels the rows and sport labels the columns, would you use a row percentage or a column percentage?

Solution

A row percentage: you look only at the Grade 12 row and divide by its total.

4. (Core) Using Example 1, find the percentage of each group (phone, no phone) that gets 88 hours or more. Does there seem to be a relationship?

Solution

Phone in bedroom: 2280=27.5%\tfrac{22}{80} = 27.5\%. No phone: 4880=60%\tfrac{48}{80} = 60\%.

Students without a phone in their bedroom were more than twice as likely to get 88 hours of sleep, so there does appear to be a relationship. (This survey can’t prove the phone causes less sleep.)

5. (Core) A survey of 150150 students:

Takes musicNo musicTotal
On a sports team424218186060
Not on a team636327279090
Total1051054545150150

Is there a relationship between being on a sports team and taking music? Use row percentages.

Solution

On a team: 4260=70%\tfrac{42}{60} = 70\% take music. Not on a team: 6390=70%\tfrac{63}{90} = 70\% take music.

The row percentages are identical (and equal to the overall 105150=70%\tfrac{105}{150} = 70\%), so there’s no evidence of a relationship in this data.

6. (Core) A survey of households:

DogCatNo petTotal
Urban545436363030120120
Rural3030454515159090
Total848481814545210210
  • (a) Find the row percentages for each type of household.
  • (b) What percentage of cat owners live in rural areas?
  • (c) Describe any relationship.
Solution

(a) Urban: dog 45%45\%, cat 30%30\%, no pet 25%25\%. Rural: dog 3090≈33.3%\tfrac{30}{90} \approx 33.3\%, cat 50%50\%, no pet 1590≈16.7%\tfrac{15}{90} \approx 16.7\%.

(b) 4581≈55.6%\tfrac{45}{81} \approx 55.6\%.

(c) Rural households in this survey were more likely to have a cat and more likely to have some pet; urban households were more likely to have a dog or no pet. Location and pet type appear to be related.

7. (Core) Students aged 1313 to 1818 were asked their favourite movie genre:

ActionComedyDramaTotal
Ages 13–154040252515158080
Ages 16–182020303030308080
Total606055554545160160

Find P(drama∣ages 16–18)P(\text{drama} \mid \text{ages 16–18}) and P(ages 16–18∣drama)P(\text{ages 16–18} \mid \text{drama}), and compare the two age groups.

Solution

P(drama∣ages 16–18)=3080=0.375P(\text{drama} \mid \text{ages 16–18}) = \tfrac{30}{80} = 0.375.

P(ages 16–18∣drama)=3045=23≈0.667P(\text{ages 16–18} \mid \text{drama}) = \tfrac{30}{45} = \tfrac{2}{3} \approx 0.667.

Row percentages: ages 13–15 are 50%50\% action, 31.25%31.25\% comedy, 18.75%18.75\% drama; ages 16–18 are 25%25\% action, 37.5%37.5\% comedy, 37.5%37.5\% drama. The younger group strongly prefers action, while the older group leans toward comedy and drama, so age and favourite genre seem related.

8. (Challenge) A survey of 200200 people includes 120120 adults and 8080 teens. 45%45\% of the adults and 75%75\% of the teens prefer streaming to cable TV (everyone chose one). Build the contingency table, then find the percentage of streamers who are teens.

Solution

Adults who stream: 0.45×120=540.45 \times 120 = 54, so 120−54=66120 - 54 = 66 prefer cable. Teens who stream: 0.75×80=600.75 \times 80 = 60, so 2020 prefer cable.

StreamingCableTotal
Adults54546666120120
Teens606020208080
Total1141148686200200

Percentage of streamers who are teens: 60114≈52.6%\tfrac{60}{114} \approx 52.6\%.

9. (Challenge) A table has three rows. Row A has 4545 “yes” and 1515 “no”. Row B has a total of 120120, and row C has a total of 4848. How many “yes” answers should rows B and C have if there’s no relationship between the row variable and the answer? Explain.

Solution

With no relationship, every row has the same percentage of “yes” answers. Row A: 4560=75%\tfrac{45}{60} = 75\%.

Row B: 0.75×120=900.75 \times 120 = 90 “yes” (and 3030 “no”). Row C: 0.75×48=360.75 \times 48 = 36 “yes” (and 1212 “no”).

Check: overall, 45+90+36228=171228=75%\tfrac{45 + 90 + 36}{228} = \tfrac{171}{228} = 75\%, the same as each row.

Try these independently after the practice questions. Show your setup and explain your reasoning. Use exact answers where possible, and check that your answers fit the question. Homework solutions are not provided on the published site.

H1. (Foundations) A school surveys students about their usual way of getting to school. Each student selects exactly one option.

WalkBusCar ride
Junior363654543030
Senior484824244848

Add every marginal total and the grand total. Check the grand total using both rows and columns.

H2. (Foundations) Use H1 to find each percentage. State its denominator before calculating.

  • (a) All surveyed students who are juniors and take the bus.
  • (b) Juniors who take the bus.
  • (c) Bus users who are juniors.

H3. (Core) Complete this table about joining an after-school club. Then find the relative frequency of Grade 10 students who joined.

JoinedDid not joinTotal
Grade 927279090
Grade 1045451515
Total150150

H4. (Core) Using H1, calculate the full set of row percentages for each group. Describe the main differences. Does this survey establish that being a senior causes a particular travel choice?

H5. (Core) Of 5050 students in Group A, 3030 prefer morning study. Of 200200 students in Group B, 8080 prefer morning study. Everyone else prefers afternoon study. Build a two-way table. Which group has more morning-study students, and which has the higher morning-study percentage? Explain why those answers differ.

H6. (Core) A table records whether students use a library.

Uses libraryDoes not use library
Group A40406060
Group B60609090

Find both row percentages, the overall percentage using the library, and the percentage of library users from Group B. Is there an observed association between group and library use in this table?

H7. (Challenge) A survey of 300300 residents includes 180180 students. There are 120120 bicycle owners, of whom 9090 are students.

  • (a) Build a table with student status as rows and bicycle ownership as columns.
  • (b) Find the probability a selected student owns a bicycle.
  • (c) Find the probability a selected bicycle owner is a student.
  • (d) Find the probability a selected resident is a student or owns a bicycle.

H8. (Challenge) Row A has an unknown number xx of “yes” responses and 2020 “no” responses. Row B has 6060 “yes” and 4040 “no” responses. Determine the integer xx that makes the row percentages identical. Complete the table and check the overall yes percentage.

H9. (Challenge) A survey of 200200 students asks for exactly one favourite activity: reading, sport, or music. There are 8080 juniors and 120120 seniors. Juniors’ preferences are 30%30\% reading, 40%40\% sport, and 30%30\% music. In the whole sample, 7070 choose reading, 9090 sport, and 4040 music.

  • (a) Reconstruct the full table.
  • (b) Find the percentage of music-preferring students who are seniors.
  • (c) Compare the junior and senior percentages preferring music.
  • (d) Explain why part (b) is a different percentage from the senior percentage in part (c).

H10. (Challenge) Of 120120 households, 7070 have a dog, 6060 have a cat, and 2525 have both. A student makes one row labelled “Dog, Cat, No pet” with counts 70,60,1570,60,15 and a total of 145145.

  • (a) Identify the counting problem. Here “no pet” is intended to mean neither a dog nor a cat; the survey did not ask about other pets.
  • (b) Build a valid two-way table with dog ownership (yes/no) as rows and cat ownership (yes/no) as columns.
  • (c) Find the percentage of dog-owning households that also own a cat, and the percentage of cat-owning households that also own a dog.
  • (d) Find the percentage owning at least one of these two animals.