AP · Statistics · Two Categorical Variables

Two-Way Tables and Association

13 min readUpdated November 30, 2026FreeAP Statistics, Exploring Two-Variable Data

A two-way table counts individuals by two categorical variables at once, and dividing a count by the right total gives a joint, marginal or conditional relative frequency. Two categorical variables are associated when the conditional relative frequencies of one variable differ across the categories of the other. Segmented and mosaic bar charts let you see those differences at a glance.

Quick check

  1. Is "how a student gets to school (walk, bus or car)" a categorical or a quantitative variable?Show answerHide answer

    Categorical: it places each student in a group rather than measuring a number.

  2. Of 150 Grade 12 students, 90 ride to school in a car. What proportion of Grade 12 students ride in a car?Show answerHide answer

    90150=0.6\dfrac{90}{150} = 0.6. This is a conditional relative frequency: the denominator is the Grade 12 total, not the whole table.

Know these already? Jump to the practice questions

What you'll be able to do

  • Calculate joint, marginal and conditional relative frequencies from a two-way table.
  • Identify which total is the denominator from the wording of a question.
  • Interpret side-by-side, segmented and mosaic bar charts.
  • Determine whether two categorical variables are associated by comparing conditional relative frequencies, and explain the conclusion in context.

Key terms

Joint relative frequency

A cell count divided by the table total.

In plain English
The proportion of everyone in both categories at once.
Don't write
"joint" for a proportion out of a row or column total.

Marginal relative frequency

A row or column total divided by the table total.

In plain English
The proportion of everyone in one category, ignoring the other variable.
Don't write
A marginal value as if it describes one subgroup.

Conditional relative frequency

A cell count divided by the total of its row or its column.

In plain English
The proportion within one group: "of the Grade 12 students…".
Don't write
A proportion out of the wrong group's total.

Association

Two categorical variables are associated if the conditional distribution of one variable differs across the categories of the other.

In plain English
The groups behave differently.
Don't write
"associated, so one causes the other".

What are joint and marginal relative frequencies?

This hypothetical table shows how 300 students get to school.

Walk or bikeBusCarTotal
Grade 9308139150
Grade 12243690150
Total54117129300

The totals in the margins give the marginal distributions: for example, the proportion of all students who ride in a car is 129300=0.43\dfrac{129}{300} = 0.43.

A joint relative frequency uses one cell: the proportion of all 300 students who are in Grade 12 and ride in a car is 90300=0.30\dfrac{90}{300} = 0.30. Joint and marginal relative frequencies both divide by the grand total.

Check yourself

What proportion of all 300 students are in Grade 9 and take the bus?
Show answerHide answer

81300=0.27\dfrac{81}{300} = 0.27, a joint relative frequency.

What is a conditional relative frequency?

A conditional relative frequency divides a cell by its row or column total. The words "of the…", "among…" or "given that…" name the group.

  • Of the Grade 12 students, the proportion who ride in a car is 90150=0.60\dfrac{90}{150} = 0.60.
  • Of the car riders, the proportion who are in Grade 12 is 90129=0.6977\dfrac{90}{129} = 0.6977.

Same cell, different groups, different denominators. One group's full set is its conditional distribution: for Grade 9, 0.20 walk or bike, 0.54 bus and 0.26 car, adding to 1.

Key idea

Find the group named after "of" or "among": its total is the denominator.

Check yourself

Of the students who walk or bike, what proportion are in Grade 9?
Show answerHide answer

3054=0.5556\dfrac{30}{54} = 0.5556. The group is the walk-or-bike column, so its total, 54, is the denominator.

How do bar charts show two categorical variables?

  • Side-by-side bar chart: a cluster of bars for each group. Use proportions, not counts, when group sizes differ.
  • Segmented bar chart: one bar per group, each of height 1, split into that group's conditional relative frequencies. For the transport table, the Grade 9 bar is split 0.20, 0.54, 0.26 and the Grade 12 bar 0.16, 0.24, 0.60.
  • Mosaic plot: a segmented bar chart whose bar widths are proportional to group sizes, so it shows the marginal distribution (widths) and the conditional distributions (segments) at once.

Segments that line up across the bars mean matching conditional distributions; clearly different heights mean association.

Check yourself

In a mosaic plot of the transport table, would the Grade 9 and Grade 12 bars have the same width?
Show answerHide answer

Yes. Both grades have 150 students, so their bars are equally wide.

How do you decide whether two variables are associated?

Compare the conditional distribution of the response variable across the groups. Here, compare transport within each grade.

Car use is 0.26 in Grade 9 and 0.60 in Grade 12; bus use is 0.54 against 0.24. The conditional distributions clearly differ, so grade and transport are associated for these students.

If the conditional distributions were the same, there would be no association.

Association is not causation: in a survey, other variables (such as having a driver's license) could explain the pattern.

Examiner's eye

Credit is lost when only one group's proportion is given. Quote a conditional proportion for each group, compare them, and state the association in context.

Check yourself

Of 200 hypothetical dog owners, 50 jog; of 100 cat owners, 25 jog. Are pet type and jogging associated?
Show answerHide answer

No. Both conditional proportions equal 0.250.25, so jogging rates are the same for the two groups.

Which method?

The question saysDenominator
"of all those surveyed", "and" (in both categories)Table total (joint)
One category, out of everyoneTable total (marginal)
"of the…", "among…", "given that…"That row or column total (conditional)
"Is there an association?"Compare conditional proportions across groups

Worked example 1: Choosing the right denominator

Question: A hypothetical survey asked 500 adults their main news source.

OnlineTVTotal
Age 18–3412832160
Age 35–5411763180
Age 55+56104160
Total301199500

Find, to four decimal places where needed, the proportion of: (a) all adults who are 55+ and prefer TV; (b) all adults who prefer online; (c) adults aged 18–34 who prefer online; (d) online-news adults who are aged 18–34.

What tells you the method

"all adults" means the table total; "adults aged 18–34" and "online-news adults" name a group whose total is the denominator.

  1. Step 1: Joint and marginal.

    (a) 104500=0.208\dfrac{104}{500} = 0.208. (b) 301500=0.602\dfrac{301}{500} = 0.602.

    Why

    Both are about all 500 adults.

  2. Step 2: Conditional on age.

    (c) 128160=0.80\dfrac{128}{160} = 0.80.

    Why

    The group is the 18–34 row, total 160.

  3. Step 3: Conditional on news source.

    (d) 128301=0.4252\dfrac{128}{301} = 0.4252.

    Why

    The group is the Online column, total 301.

Check it

The 18–34 row adds to 1: 0.80+32160=10.80 + \dfrac{32}{160} = 1.

Answer

(a) 0.2080.208 (b) 0.6020.602 (c) 0.800.80 (d) 0.42520.4252

Worked example 2: Is there an association?

Question: Hypothetical survey data for 300 students:

Has a jobNo jobTotal
Completed all homework42168210
Did not385290
Total80220300

Is having a job associated with completing all homework for these students? Justify with conditional proportions to four decimal places, and say whether the data show that jobs cause lower completion.

What tells you the method

"associated" means compare conditional proportions of homework completion across the job groups.

  1. Step 1: Conditional proportions.

    Job: 4280=0.525\dfrac{42}{80} = 0.525. No job: 168220=0.7636\dfrac{168}{220} = 0.7636.

    Why

    The groups differ in size, so each uses its own column total.

  2. Step 2: Compare.

    0.5250.525 is well below 0.76360.7636.

    Why

    Different conditional distributions mean the variables are associated.

  3. Step 3: Causation.

    This is a survey, so it cannot show that jobs cause lower completion; students with jobs may differ in other ways, such as grade level.

    Why

    Only a randomized experiment supports cause and effect.

Check it

Counts would mislead: more students without jobs missed homework (52 against 38), yet their proportion is lower.

Answer

Yes: 0.5250.525 of students with a job completed all homework, against 0.76360.7636 without one. The survey cannot show that jobs cause lower completion.

Your turn

Question: In a hypothetical survey, 72 of 120 Plan A customers and 48 of 80 Plan B customers were satisfied. Are plan and satisfaction associated?

  1. Step 1:

    Plan A: 72120=0.6\dfrac{72}{120} = 0.6 satisfied.

  2. Step 2: Your go: find the proportion of Plan B customers who are satisfied, compare and conclude.

Show the full solutionHide the solution

Plan B: 4880=0.6\dfrac{48}{80} = 0.6. The conditional proportions are equal (and so are the "not satisfied" proportions, 0.4 each), so knowing the plan does not change the chance of satisfaction.

Answer: No association: the proportion satisfied is 0.60.6 for both plans.

Traps

Trap

Dividing by the column total when the question names a row group.

It seems right because the cell is correct. But "of the Grade 12 students" means divide by the Grade 12 total, 150, giving 0.60; the car total, 129, answers a different question.

Check yourself

Which answers "Of the car riders, what proportion are in Grade 12?": 90150\dfrac{90}{150} or 90129\dfrac{90}{129}?
Show answerHide answer

90129=0.6977\dfrac{90}{129} = 0.6977. The group is the car riders, so their total, 129, is the denominator.

Trap

Comparing counts to judge association when the groups differ in size.

It seems right because a bigger count looks like a stronger effect. But a larger group has larger counts just from its size, so compare conditional proportions.

Check yourself

Group A has 30 "yes" answers out of 60; Group B has 40 out of 100. Which group has the higher proportion of "yes"?
Show answerHide answer

Group A: 0.50.5 against 0.40.4, even though Group B has more "yes" answers.

What's examined

Two-way tables appear on the AP® Statistics exam (Two-variable data), in multiple-choice and free-response questions, with command words such as Calculate, Compare and Justify. Later, a chi-square test decides whether an association in sample data is convincing evidence about a population.

Practice questions

  1. Recall What type of relative frequency is "the proportion of all students surveyed who are in Grade 9 and walk or bike"?
    • A) Marginal
    • B) Conditional
    • C) Joint
    • D) Cumulative
Show answer

Answer: C) Joint

Marking points:

  • One cell (Grade 9 and walk or bike) divided by the table total is a joint relative frequency.
  • A uses a row or column total as the numerator. B divides by a row or column total. D adds up proportions across ordered categories.
  1. Apply In a hypothetical survey of 200 adults, 54 of the 120 daily coffee drinkers sleep 7 hours or more and 66 sleep less; of the 80 others, 56 sleep 7 hours or more and 24 sleep less. Find, to four decimal places, the proportion of (a) coffee drinkers who sleep under 7 hours and (b) under-7-hour sleepers who drink coffee daily.
Show answer

Answer: (a) 0.550.55 (b) 0.73330.7333

Marking points:

  • (a) The group is coffee drinkers: 66120=0.55\dfrac{66}{120} = 0.55.
  • (b) The group is short sleepers, 66+24=9066 + 24 = 90 adults: 6690=0.7333\dfrac{66}{90} = 0.7333.
  1. Apply Using the coffee data in question 2, which comparison best shows whether coffee drinking and sleep are associated?
    • A) 54120\dfrac{54}{120} compared with 5680\dfrac{56}{80}
    • B) 5454 compared with 5656
    • C) 110110 compared with 9090
    • D) 54200\dfrac{54}{200} compared with 56200\dfrac{56}{200}
Show answer

Answer: A) 54120\dfrac{54}{120} compared with 5680\dfrac{56}{80}

Marking points:

  • A compares the conditional proportion sleeping 7 hours or more in each group: 0.45 against 0.70.
  • B compares counts from groups of different sizes. C compares the marginal totals of one variable. D compares joint proportions, which still depend on group size.
  1. Exam-style In a hypothetical survey of 250 students, 24 of the 60 who play an instrument named math as their favorite subject, as did 56 of the 190 who do not. (a) Find each group's proportion naming math, to four decimal places. (b) Do these data suggest an association between playing an instrument and naming math? Justify your answer.
Show answer

Answer: (a) Players 0.400.40, non-players 0.29470.2947. (b) Yes: a higher proportion of players than non-players named math, so the variables are associated for these students.

Marking points:

  • 2460=0.40\dfrac{24}{60} = 0.40 and 56190=0.2947\dfrac{56}{190} = 0.2947.
  • The conclusion compares the two conditional proportions and is stated in context.
  • It does not claim that playing an instrument causes a preference for math.
  1. Recall In a mosaic plot, what does the width of each bar show?
    • A) The conditional relative frequency of each segment
    • B) The count in each cell
    • C) The joint relative frequency of each cell
    • D) The proportion of all individuals in that bar's group
Show answer

Answer: D) The proportion of all individuals in that bar's group

Marking points:

  • Widths are proportional to group sizes, which is the marginal distribution.
  • A is shown by segment heights, not widths. B and C are shown by the areas of the rectangles, not the bar widths.
  1. Apply Of 120 hypothetical customers at Store A, 66 rated service "Good". Of 300 at Store B, 150 did. Which statement is supported?
    • A) Store B has better service, because more customers rated it "Good".
    • B) A higher proportion of Store A's customers rated service "Good".
    • C) There is no association, because both proportions are about one half.
    • D) Shopping at Store A causes higher ratings.
Show answer

Answer: B) A higher proportion of Store A's customers rated service "Good": 0.55 against 0.50.

Marking points:

  • 66120=0.55\dfrac{66}{120} = 0.55 and 150300=0.50\dfrac{150}{300} = 0.50.
  • A compares counts from groups of different sizes. C ignores a difference of 0.05 in the proportions. D claims causation from observational data.
  1. Exam-style In a hypothetical survey of 400 people, 35% are under 30. Of those under 30, 60% prefer texting to calling; of the rest, 25% do. (a) How many people prefer texting? (b) What proportion of texters are under 30? Give four decimal places.
Show answer

Answer: (a) 149149 people (b) 0.56380.5638

Marking points:

  • Under 30: 0.35×400=1400.35 \times 400 = 140, and 0.60×140=840.60 \times 140 = 84 prefer texting. Others: 260260, and 0.25×260=650.25 \times 260 = 65.
  • (a) 84+65=14984 + 65 = 149.
  • (b) The group is texters: 84149=0.5638\dfrac{84}{149} = 0.5638.

Key points

Recall, then reveal

Say the main points from memory first, then check them.

Show key pointsHide key points
  • Joint and marginal relative frequencies divide by the table total; conditional ones divide by a row or column total.
  • The group after "of" or "among" sets the denominator, so "of the car riders" and "of the Grade 12 students" give different answers from the same cell.
  • Segmented bar charts show conditional distributions; mosaic plots also show group sizes through bar widths.
  • Variables are associated when conditional distributions differ across groups; compare proportions, not counts.
  • Association from a survey does not show cause and effect.

Keep learning

Explore AP Statistics tutoring →

View the full Statistics syllabus →

More in this unit

Exploring Two-Variable Data

All Two Categorical Variables notes

Part of Novark's AP Statistics notes