From the free course AP Statistics on Lykke
2.1 Tabular and Graphical Representations for the Distributions of Two Categorical Variables
Key concepts: Two-way (contingency) table of counts or relative frequencies · Conditional distribution — the breakdown within one row or column · Side-by-side bar chart — compares counts across the groups · Segmented bar chart — every bar stands for 100% of its group · Mosaic plot — bar width also shows how big each group is · Association — the conditional distributions differ across groups
Bivariate categorical analysis shifts the focus from describing a single characteristic to investigating the relationship between two qualitative variables. When we collect data on two categorical variables for each observational unit—such as a person's vaccination status and their health…
Bivariate categorical analysis shifts the focus from describing a single characteristic to investigating the relationship between two qualitative variables. When we collect data on two categorical variables for each observational unit—such as a person's vaccination status and their health outcome—we seek to determine if the distribution of one variable depends on the level of the other. This relationship is the foundation of statistical association.
The Two-Way Table (Contingency Table)
The primary tool for organizing bivariate categorical data is the two-way table, also known as a contingency table (CED 2.1.A.1). This table summarizes the relationship by displaying the frequencies (counts) or relative frequencies (proportions) of the intersections between the categories of two variables. One variable defines the rows, while the other defines the columns.
Definition: A two-way table is a tabular representation where the rows represent the levels of one categorical variable and the columns represent the levels of another. Each "cell" in the table contains the count or proportion of individuals who fall into that specific combination of categories.
Comparing Graphical Representations
To visualize the relationship between two categorical variables, we use specialized charts that allow for direct comparison across groups (CED 2.1.A.2). While a simple bar chart handles one variable, bivariate data requires displays that "stack" or "group" the data to reveal patterns.
1. Side-by-Side Bar Charts
In a side-by-side bar chart, bars for the categories of one variable are placed next to each other for every level of the second variable. This is highly effective for comparing raw counts (frequencies) across groups. However, if the group sizes are vastly different, comparing counts can be misleading, making relative frequencies a safer choice for comparison (Skill 4.A).
2. Segmented Bar Charts
A segmented bar chart (or stacked bar chart) treats each level of the "explanatory" variable as a single bar representing 100%. This bar is then divided into segments proportional to the relative frequencies of the "response" variable. This format makes it easy to see if the "makeup" of one group differs from another.
3. Mosaic Plots
A mosaic plot is a more advanced version of the segmented bar chart. While the heights of the segments still represent the relative frequency of the response variable, the widths of the bars are adjusted to represent the relative frequency of the categories on the horizontal axis (CED 2.1.A.2). This allows the viewer to see both the relationship between variables and the relative sizes of the groups being compared simultaneously.
Identifying Association (Skill 4.B)
The ultimate goal of these representations is to determine if an association exists between the two variables (CED 2.1.A.3). Two categorical variables are associated if knowing the value of one variable helps predict the value of the other.
- No Association: If the segmented bar charts or mosaic plots look identical across all groups (the segments are the same height), the variables are not associated.
- Association Present: If the distribution of the segments changes significantly from one bar to the next, we have evidence of an association (CED 2.1.B.1).
Contextual Example: Subscription Tiers and Device Type
Imagine a streaming service analyzing whether the type of device used (Mobile vs. TV) is associated with the subscription tier (Basic vs. Premium).
| Device | Basic | Premium | Total |
|---|---|---|---|
| Mobile | 400 | 100 | 500 |
| TV | 150 | 350 | 500 |
In a segmented bar chart, the "Mobile" bar would be 80% Basic and 20% Premium. The "TV" bar would be 30% Basic and 70% Premium. Because these distributions are different, we justify the claim that an association exists: TV users are more likely to choose Premium subscriptions than Mobile users (Skill 4.B).
Misconception Check: Frequency vs. Relative Frequency
A common error is concluding an association exists based solely on raw counts when group sizes are unequal. For example, if 100 people in Group A like a product and only 50 people in Group B like it, you cannot claim Group A is "more likely" to like it without knowing the total number of people in each group. Always use relative frequencies (percentages or proportions) when comparing groups of different sizes to avoid this "size bias."
Interpretation Check
A researcher creates a mosaic plot comparing "Exercise Habit" (Regular vs. Occasional) and "Sleep Quality" (Good vs. Poor). The bar for "Regular Exercise" is much wider than the bar for "Occasional Exercise," and the "Good Sleep" segment in the "Regular" bar is significantly taller than the "Good Sleep" segment in the "Occasional" bar.
- What does the wider bar for "Regular Exercise" tell you about the sample?
- Does this plot suggest an association between exercise and sleep quality? Justify your answer.
Check your reasoning:
- The wider bar indicates that there were more "Regular Exercisers" in the study's sample than "Occasional Exercisers."
- Yes, an association is suggested. Because the height of the "Good Sleep" segment changes (it is taller for regular exercisers), the distribution of sleep quality depends on exercise habits.

Source Materials
Study AP Statistics on Lykke
This course page is free to open: signed out, you can read its first two sections, and signing in, on any plan, opens the rest. The free Lykke Chrome extension syncs your own Canvas courses, so ChatGPT, Claude and Muse can answer from your classes and deadlines. It only reads Canvas.
Add the free extensionSign in to open every section