When a survey asks two categorical questions, we organize the counts into a two-way table to see how the two variables relate.
1
Two-Way Tables, Marginal Distributions, and Joint Percentages
Suppose we survey 200 students after an exam and ask where they did most of their studying (Library, Bedroom, or Coffee Shop) and whether they passed or failed. If 60 students passed after studying in their bedroom and only 40 passed after studying in the library, does the bedroom give you a better chance of passing? To find out, we first need the group totals along the margins of the table.
Two-Way Tables, Marginal Distributions, and Joint Percentages
Text solution
Add the rows and columns to find the margin totalsAdding across the rows and down the columns gives the total for each category along the edges of the table:
Divide a margin by the grand total for a marginal distributionLooking at one margin at a time tells us how all 200 students split across a single variable while ignoring the other:
marginal distribution of study locationLibraryBedroomCoffee Shop:20050=25%,:200100=50%,:20050=25%
marginal distribution of exam resultPassedFailed:200120=60%,:20080=40%
Divide an inside cell by the grand total for a joint percentageDividing a single interior cell by all 200 students gives the share of the entire survey that falls into both categories at once:
joint percentageLibrary and Passed=20040=20%
2
Conditional Distributions and Choosing the Right Denominator
Dividing by all 200 students still doesn't tell us whether library studiers or bedroom studiers had a higher pass rate, because twice as many students studied in their bedroom (100 vs. 50). A conditional distribution looks at one group at a time and makes that group its own 100%.
Conditional Distributions and Choosing the Right Denominator
Text solution
Make each study location its own 100% groupTo compare exam results fairly across study locations, divide the counts in each location column by that column's own total:
Use the condition after "of" to choose the denominatorWhen a question asks about the 40 students who studied in the library and passed, 40 stays in the numerator while the group we focus on goes in the denominator:
Percent of library studierswho passed=library total5040=80%Percent of passing studentswho studied in the library=passed total12040≈33.3%
So the library had the highest pass rate at 80% compared to 60% in the bedroom, though an observational survey only shows an association and cannot prove that the study location itself caused higher grades.
In this table, the count of 40 students in the Library-and-Passed cell never changes, but its percentage changes between 20%,80%, and 33.3% depending on whether the whole table, the Library column, or the Passed row is the 100% group in the denominator.
The count inside each cell never changes, but its percentage changes completely depending on which group becomes the whole.
3
Association Between Categorical Variables
Now we want to know whether our table shows an association between study location and exam result, meaning that knowing where a student studied changes our prediction of whether they passed.
Association Between Categorical Variables
Text solution
Find the counts we would expect if there were no associationIf study location had no relationship with passing, every location would match the overall marginal pass rate of 200120=60%, even though the raw counts still differ because the bedroom group is twice as large:
Compare the actual conditional percentages across groupsIn our actual data, the pass rate changes from group to group, which tells us there is an association between study location and exam result:
When a question asks whether two variables are associated, don't stop at "Yes, because the percentages are different." Always back it up with the conditional percentages from the table (80% of library studiers passed, compared to 60% in the bedroom and 40% at the coffee shop).
4
Segmented Bar Graphs, Side-by-Side Bars, and Mosaic Plots
Once we have the conditional percentages for each group, we want a graph that makes an association easy to see at a glance. And when group sizes matter too, we need a graph that shows the marginal totals that equal-width bars leave out.
Segmented Bar Graphs, Side-by-Side Bars, and Mosaic Plots
Text solution
Read the marginal percentage from the bar widthIn a mosaic plot, each column's width matches that group's share of all 200 students:
Width (Bedroom)=200100=50%
Read the conditional percentage from the section heightThe vertical split inside each bar shows the pass rate within that single location:
Height (Passed in Bedroom)=10060=60%
Multiply width by height for the joint percentageThe area of each rectangle gives the share of all 200 students who are in that specific cell:
In this mosaic plot, when the pass/fail dividers line up flat across all three bars, there is no association, even though the wider Bedroom bar has twice as many passing students as the Library bar. As soon as the dividers step to different heights, an association appears.
Even when the bars have different widths, flat dividers across them mean there is no association, and stepped dividers mean the pass rate changes by study location.
5
Lurking Variables and Simpson's Paradox
Even conditional percentages can mislead us when a hidden third variable, called a lurking variable, is split unevenly across our groups. When splitting the data by that third variable reverses the direction of the association, we get Simpson's Paradox.
Lurking Variables and Simpson's Paradox
Text solution
Compare pass rates within each preparation subgroupSplitting the 50 Library students and 100 Bedroom students into Prepared Students and Late-Night Crammers shows that the Bedroom has the higher pass rate in both groups:
Combine the subgroups into the overall tableAdding the two tables back together puts mostly prepared students in the Library (40 of 50) and mostly crammers in the Bedroom (75 of 100), reversing which location has the higher overall pass rate:
Here the Bedroom has the higher pass rate in both subgroups (96% vs. 90% among Prepared Students, and 48% vs. 40% among Late-Night Crammers). Still, having mostly crammers in the Bedroom and mostly prepared students in the Library pulls the Bedroom's combined pass rate below the Library's.
Even when the Bedroom has a higher pass rate in both groups, changing the mix of prepared students and crammers in each room can flip which room has the higher overall pass rate.
Key concepts
Let's pull together the four connected ideas behind every two-way table.
Four Key Ideas of Two-Way Tables
Every percentage in a two-way table comes down to picking the denominator that matches who counts as the whole 100% group:
Stay with the grand total when no condition restricts the group
If a question asks for the breakdown of a single variable on its own (marginal distribution, like Bedroom=200100=50%) or the share of everyone surveyed who falls into two categories at once (joint percentage, like Library and Passed=20040=20%), do not divide by a row or column total. Keep the grand total (200) on the bottom.
Divide by the subgroup total when a condition restricts who you look at
For a conditional distribution, put the total of the group following "of," "among," or "given that" in the denominator (Passed among Library=5040=80%, whereas Library among Passed=12040≈33.3%). When one variable helps explain or predict the other, make each category of that explanatory variable its own 100% group.
Test for association with conditional percentages, never raw counts
Two variables have an association when the conditional percentages change across categories (80%,60%,40%); if the conditional percentages are the same (60%,60%,60%), there is no association even when uneven group sizes make the raw counts differ (30,60,30). On a mosaic plot, bar width shows the marginal percentage, section height shows the conditional percentage, and rectangle area (Width×Height) shows the joint percentage.
Check who is in each group before trusting combined totals
In Simpson's Paradox, a lurking variable splits unevenly across the groups (like having 75 of 100 Bedroom studiers be late-night crammers). That uneven mix can pull one group's combined rate below another's, even when it has the higher rate inside every subgroup.
6
Practice
1
A campus dining survey asks 250 students two questions: their meal plan (Full, Partial, or None) and where they eat lunch most often (Dining Hall or Off Campus). In the Dining Hall row, the counts are Full 90, Partial 45, and None 15. In the Off Campus row, the counts are Full 10, Partial 30, and None 60. Find the marginal distribution of meal plans as percentages, and find the joint percentage of students who have a Partial meal plan and eat Off Campus.
Add down each meal-plan column first, then ask: for a marginal or joint percentage, who is the whole 100% group?
Add each meal-plan column to find the margin totals out of all 250 students:
FullPartialNone=90+10=100,=45+30=75,=15+60=75
Divide each column total by the grand total of 250 for the marginal distribution of meal plans:
For the joint percentage of students who have a Partial meal plan and eat Off Campus, divide that cell's count (30) by the grand total of 250. Be careful not to divide by the Partial column total (7530=40%) or the Off Campus row total (10030=30%), which gives a conditional percentage instead of a joint percentage:
Partial and Off Campus=25030=12%
2
Using the same dining survey of 250 students (where 45 students have a Partial meal plan and eat in the Dining Hall, 75 students in total have a Partial meal plan, and 150 students in total eat in the Dining Hall), find: (a) what percent of students on a Partial meal plan eat in the Dining Hall, and (b) what percent of students who eat in the Dining Hall are on a Partial meal plan.
Be careful not to swap the two totals (which reverses the answers to 30% and 60%) or divide by the grand total of 250 (25045=18%).
Both parts use the same 45 students in the numerator; look right after "of" in each question to see which margin total belongs in the denominator.
Both questions keep the 45 students who are in both categories on top, while the condition after "of" picks the denominator. Be careful not to swap the two totals (which reverses the answers to 30% and 60%) or divide by the grand total of 250 (25045=18%):
(a) Of students on a Partialmeal plan (75):7545=60%(b) Of students who eatin the Dining Hall (150):15045=30%
3
A teacher surveys 160 students on how they take lecture notes (By Hand or On a Laptop) and whether they earned an A on the unit exam. Among those who took notes By Hand, 24 earned an A and 16 scored below an A. Among those who took notes On a Laptop, 48 earned an A and 72 scored below an A. A friend says, "48 laptop users got an A compared to only 24 hand-writers, so using a laptop helps you get an A." Calculate the appropriate conditional distributions to evaluate your friend's claim, state with numbers whether there is an association, and explain whether the table proves that note-taking method causes exam results.
Don't compare the raw counts (48 vs. 24) or divide down the "Earned an A" column (7224≈33.3% and 7248≈66.7%), which ignores that three times as many students used laptops (120 vs. 40).
Note-taking method is the explanatory variable; find the total number of students in each note-taking group so you can make each group its own 100%.
Find the total for each note-taking group so each category of the explanatory variable becomes its own 100% group. Don't compare the raw counts (48 vs. 24) or divide down the "Earned an A" column (7224≈33.3% and 7248≈66.7%), which ignores that three times as many students used laptops (120 vs. 40):
By Hand (24+16=40):Earned an ABelow an AOn a Laptop (48+72=120):Earned an ABelow an A=4024=60%,=4016=40%=12048=40%,=12072=60%
Your friend was misled by raw counts because the laptop group is three times as large (120 vs. 40). Yes, there is an association between note-taking method and exam result, in the opposite direction of your friend's claim, because 60% of hand-writers earned an A compared to only 40% of laptop users. However, this observational table only shows an association and does not prove cause and effect, since students who choose to take notes by hand may already differ in other ways.
4
A survey of 300 commuters records their transit method (Train: 50, Car: 150, Bus: 100) and whether they arrived at work on time (On Time total: 210, Late total: 90). If there were no association at all between transit method and arriving on time, how many commuters in each transit group would arrive on time, and why would those raw counts still differ from group to group?
Be careful not to split the 210 on-time commuters equally across the three columns (3210=70 per group), which ignores the different group sizes.
First find the overall marginal percentage of commuters who arrived on time out of all 300 commuters, then apply that rate to each transit group.
First find the overall marginal on-time rate across all 300 commuters:
Overall On Time rate=300210=70%
If there were no association, every transit group would have that exact same 70% on-time rate. Be careful not to split the 210 on-time commuters equally across the three columns (3210=70 per group), which ignores the different group sizes:
Train:70%×50Car:70%×150Bus:70%×100=35,=105,=70
The raw counts (35,105, and 70) still differ from group to group only because the group sizes are unequal (50,150, and 100), while the conditional on-time percentage is 70% in all three groups.
5
A mosaic plot summarizes a study of 400 subscribers across three plan tiers (Basic, Plus, Premier) and whether they renewed (Renewed vs. Canceled). The widths of the bars are 50% for Basic, 30% for Plus, and 20% for Premier, and the heights of the Renewed sections are 40% for Basic, 70% for Plus, and 85% for Premier. From this plot, find the marginal percentage of Plus subscribers, the conditional percentage of Plus subscribers who renewed, and the joint percentage and exact number of all 400 subscribers who are in the Plus tier and renewed. Also explain what tells you there is an association and what information this mosaic plot keeps that a segmented bar graph leaves out.
Match width, height, and rectangle area (Width×Height) to marginal, conditional, and joint percentages.
Read the marginal and conditional percentages for the Plus tier directly from the bar width and section height:
Marginal percentage(Plus width)Conditional percentage(Renewed height in Plus)=30%,=70%
Multiply width by height to find the joint percentage and apply it to all 400 subscribers. Don't mistake the 70% conditional height for the share of all 400 subscribers (70%×400=280 subscribers), because 70% is only out of the Plus tier:
There is an association because the dividing line for the Renewed section steps up from 40% to 70% to 85% across the bars instead of staying flat. Unlike a segmented bar graph where all bars have equal width, the mosaic plot scales the bar widths to show the marginal group sizes (50%,30%,20%) and uses the rectangle areas to show the joint percentages.
6
Two tech-support teams (Team A and Team B) each handle 100 repair tickets, split into Easy Tickets and Hard Tickets. On Easy Tickets, Team A resolves 72 out of 80 and Team B resolves 19 out of 20. On Hard Tickets, Team A resolves 8 out of 20 and Team B resolves 36 out of 80. Compare the resolution percentages of Team A and Team B within Easy Tickets, within Hard Tickets, and when each team's 100 tickets are combined into one table. Name what happens here and explain why the combined table reverses the comparison.
Find the resolution percentage for each team inside Easy Tickets and inside Hard Tickets, then add each team's resolved tickets out of all 100 tickets.
Compare the conditional resolution percentages within each difficulty level:
Team B>Team ATeam B>Team AEasy Tickets:=2019=95%=8072=90%Hard Tickets:=8036=45%=208=40%
Now combine each team's 100 total tickets by adding the raw counts. Do not simply average the two percentages equally as 290%+40%=65% and 295%+45%=70%, because the subgroups do not have equal numbers of tickets:
Combined Team ACombined Team B=80+2072+8=10080=80%>=20+8019+36=10055=55%
Team B has a higher resolution rate in both subgroups, yet Team A has a higher rate overall by 25 percentage points (80% vs. 55%). This reversal is Simpson's Paradox: it happens because 80 of Team A's 100 tickets came from the Easy group (where resolution rates are high at 90% to 95%), whereas 80 of Team B's 100 tickets came from the Hard group (where resolution rates are low at 40% to 45%), pulling down Team B's combined rate.