SECTION 1
Historical Context & Motivation
Long before the formal machinery of statistical inference was developed, researchers recognized that understanding relationships between categorical attributes—such as occupation and literacy, or treatment type and patient outcome—required more than simple one-variable frequency counts. The challenge was clear: when two categorical variables each have multiple levels, summarizing every possible combination of categories demands a structured, tabular approach. The two-way table (also called a contingency table) emerged as the foundational tool for organizing such data, and its development parallels the rise of quantitative social science.
1693 • Halley's Mortality Table
1900 • Pearson's Chi-Square Test
1922 • Fisher and the Contingency Table
1977 • Exploratory Data Analysis (EDA)
The central question this topic addresses is deceptively simple: Is there a relationship between two categorical variables, and how can we display and quantify that relationship? To answer it, we need tools that organize raw counts into meaningful summaries and graphical displays that make patterns—and their absence—visually apparent. This section of the AP Statistics curriculum equips you with exactly those tools.
SECTION 2
Core Principles & Definitions
Before constructing any table or chart, it is essential to have a firm grasp of the key vocabulary. A categorical variable places each individual into one of several groups or categories; examples include political affiliation, blood type, or preferred mode of transportation. When we observe two categorical variables for each individual in a dataset, we can organize the counts into a two-way table (also called a contingency table), where rows represent the categories of one variable and columns represent the categories of the other.
Joint Frequency
Marginal Frequency
Conditional Distribution
Marginal Distribution
Association vs. Independence
KEY TAKEAWAY
SECTION 3
Visual Explanation: The Two-Way Table
The diagram below presents a two-way table for a hypothetical survey of 400 college students cross-classified by class year (Freshman, Sophomore, Junior, Senior) and preferred study method (Alone, Group, Online). Joint frequencies appear in the interior cells; marginal frequencies are displayed along the right edge and bottom row. Observe how the marginal totals for each row sum to the row total, and the marginal totals for each column sum to the column total; both grand totals equal 400.
Notice the structural anatomy of the table. The intersection of the Freshman row and the Alone column yields the joint frequency 50, meaning 50 freshmen in the sample prefer studying alone. The row total for Freshmen (120) is the marginal frequency of the Freshman category, obtained by summing 50 + 30 + 40. Similarly, the column total for Alone (140) sums 50 + 35 + 30 + 25. The grand total of 400 in the bottom-right corner serves as a quick check: every row total and every column total must each sum to 400.
SECTION 4
Mathematical Framework: Proportions & Distributions
Raw counts are informative, but proportions allow us to make meaningful comparisons—especially when row or column totals are unequal. There are three types of proportions commonly extracted from a two-way table: joint relative frequencies, marginal relative frequencies, and conditional relative frequencies. Each answers a fundamentally different question.
JOINT RELATIVE FREQUENCY
For example, the joint proportion of Freshmen who study Alone = 50 / 400 = 0.125 (or 12.5%). This answers: "What fraction of all students are both Freshmen and prefer Alone?"
MARGINAL RELATIVE FREQUENCY
For example, the marginal proportion of Freshmen = 120 / 400 = 0.30. This answers: "What fraction of all students are Freshmen, regardless of study method?"
CONDITIONAL RELATIVE FREQUENCY (ROW-BASED)
For example, among Freshmen only, the conditional proportion who study Alone = 50 / 120 ≈ 0.417 (41.7%). This answers: "Of the Freshmen, what fraction prefer studying Alone?" Comparing these across rows is the primary method for detecting association.
CONDITIONAL RELATIVE FREQUENCY (COLUMN-BASED)
For example, among those who study Alone, the conditional proportion who are Freshmen = 50 / 140 ≈ 0.357. This answers: "Of those who study Alone, what fraction are Freshmen?"
AP Exam Tip
SECTION 5
Graphical Displays: Segmented & Side-by-Side Bar Charts
While the two-way table is the computational backbone, graphical representations make associations (or their absence) immediately visible. The AP Statistics curriculum emphasizes two primary chart types for two categorical variables: segmented (stacked) bar charts and side-by-side bar charts. A segmented bar chart displays the conditional distribution of one variable within each category of the other by stacking colored segments to fill each bar to 100%. If the segment proportions are roughly the same across all bars, the variables appear independent; if the proportions shift noticeably, an association is suggested.
The chart makes the association visually apparent. The cyan segment (Alone) shrinks from 41.7% for Freshmen to 27.8% for Seniors, while the violet segment (Group) grows from 25.0% to 50.0%. If the two variables were independent—meaning class year had no relationship with study preference—all four bars would have essentially identical segment proportions. The visible differences suggest that as students advance through college, they increasingly prefer group study. A side-by-side bar chart would display the same information by placing separate bars for each study method next to one another within each class-year group, making it easier to compare absolute heights but harder to see proportional composition.
SECTION 6
Worked Example
A health researcher surveys 500 adults about their exercise frequency (Regular, Occasional, None) and whether they report high stress levels (Yes, No). The data are shown in the table below. Determine whether there appears to be an association between exercise frequency and high stress.
| High Stress: Yes | High Stress: No | Total | |
|---|---|---|---|
| Regular | 40 | 160 | 200 |
| Occasional | 60 | 90 | 150 |
| None | 90 | 60 | 150 |
| Total | 190 | 310 | 500 |
Two-way table: Exercise Frequency × High Stress
Detecting Association via Conditional Distributions
- 1
Step 1 — Identify the Variables
The explanatory variable is exercise frequency (Regular, Occasional, None) and the response variable is high stress (Yes, No). We will compute the conditional distribution of high stress for each level of exercise frequency. - 2
Step 2 — Compute Conditional Proportions of High Stress
For each exercise group, divide the number reporting high stress by the row total. Regular: 40 / 200 = 0.20 (20%). Occasional: 60 / 150 = 0.40 (40%). None: 90 / 150 = 0.60 (60%).Regular → 20%, Occasional → 40%, None → 60% - 3
Step 3 — Compare the Conditional Distributions
The conditional proportion of high stress differs substantially across the three exercise groups: it triples from 20% (Regular) to 60% (None). If exercise frequency and high stress were independent, all three conditional proportions would be approximately equal to the marginal proportion of high stress, which is 190 / 500 = 0.38 (38%). - 4
Step 4 — State Your Conclusion in Context
Because the conditional proportions of high stress vary considerably across exercise-frequency groups (20%, 40%, 60%), there appears to be an association between exercise frequency and high stress. Adults who exercise regularly report high stress at a much lower rate than those who exercise occasionally or not at all.Conclusion: There is an association between exercise frequency and reporting high stress.
Caution: Association ≠ Causation
SECTION 7
Strengths & Limitations of Graphical Displays
Different graphical displays of two categorical variables emphasize different aspects of the data. Choosing the right display depends on whether your goal is to compare conditional proportions, compare counts, or show the overall composition. The table below summarizes the strengths and limitations of the most common options.
| Display Type | Best For | Limitations |
|---|---|---|
| Two-Way Table | Precise counts and proportions; computing conditional distributions; the essential starting point for any analysis | Not a visual display; patterns can be hard to spot in large tables with many categories |
| Segmented Bar Chart | Comparing conditional distributions across groups; detecting association at a glance | Difficult to compare middle segments accurately; does not show sample sizes unless annotated |
| Side-by-Side Bar Chart | Comparing absolute counts or proportions for specific categories; easy to read individual bar heights | Harder to see the full conditional distribution within each group; chart can become cluttered with many categories |
| Mosaic Plot | Showing both conditional proportions and relative group sizes in a single display | Less intuitive to read; not explicitly tested on the AP exam, but appears occasionally |
Comparison of common displays for two categorical variables
KEY TAKEAWAY
SECTION 8
Connection to Inference: The Chi-Square Test
Everything covered so far—two-way tables, conditional distributions, and segmented bar charts—belongs to the exploratory data analysis (EDA) stage of statistics. We can describe patterns and note apparent associations, but we cannot yet determine whether those patterns are statistically significant or could have arisen by chance. That is the role of inferential statistics, specifically the chi-square test for independence, which you will encounter later in the AP Statistics curriculum.
| Feature | Descriptive (This Lesson) | Inferential (Chi-Square Test) |
|---|---|---|
| Goal | Summarize and display the relationship between two categorical variables in a sample | Determine whether a relationship observed in a sample provides convincing evidence of a relationship in the population |
| Tools | Two-way tables, segmented bar charts, conditional proportions | Expected counts, chi-square statistic (χ²), p-values, degrees of freedom |
| Output | "There appears to be an association..." | "There is statistically significant evidence of an association (p < 0.05)..." |
| Scope | Limited to the sample at hand | Generalizes from sample to population under stated conditions |
Descriptive analysis (this lesson) vs. inferential chi-square test (later unit)
Mastering the descriptive skills in this lesson is essential groundwork for the chi-square test. The expected counts used in that test are derived from the marginal totals you already know how to compute, and the test statistic measures how far the observed joint frequencies deviate from what we would expect under independence. In other words, the chi-square test formalizes exactly the kind of comparison you perform when you eyeball a segmented bar chart and decide whether the segment proportions look "different enough" to matter.
SECTION 9
Practice Problems
Question 1: CONCEPTUAL
- A. The joint frequencies in each cell of the table
- B. The marginal distributions of both variables
- C. The conditional distributions of opinion for each party
- D. The grand total of the table against the individual cell counts
- E. The row totals to see which party has the most members
Show answer (C)
Question 2: BASIC CALCULATION
- A. 0.18
- B. 0.30
- C. 0.50
- D. 0.60
- E. 0.53
Show answer (D)
Question 3: INTERMEDIATE
- A. More people in Neighborhood A drive cars than in Neighborhood B.
- B. There is an association between neighborhood and transportation mode because the conditional distributions differ.
- C. Living in Neighborhood A causes residents to prefer driving.
- D. The marginal distribution of transportation mode is 60% Car, 25% Bus, 15% Bike.
- E. Bus is the most popular transportation mode overall.
Show answer (B)
Question 4: APPLIED
4 ptsShow answer
Question 5: CRITICAL THINKING
4 ptsShow answer
SUMMARY
Summary & Review
Summary
Representing two categorical variables begins with the two-way table, which organizes raw counts into joint frequencies (interior cells) and marginal frequencies (row and column totals). From the table, we compute three types of proportions: joint relative frequencies (cell ÷ grand total), marginal relative frequencies (row or column total ÷ grand total), and conditional relative frequencies (cell ÷ row or column total). The conditional distributions are the key to detecting association.
Graphically, segmented bar charts and side-by-side bar charts are the primary tools for visualizing these relationships. Two variables are associated if the conditional distributions of one variable differ across the categories of the other; they are independent if the conditional distributions are approximately equal. Always remember: association does not imply causation, and beware of Simpson's Paradox, in which a lurking variable can reverse an apparent trend when data are aggregated.