SECTION 1
Historical Context & Motivation
The analysis of categorical data has deep roots in the history of statistics, arising from a fundamental need to understand relationships that cannot be captured by numerical measurements alone. When researchers want to know whether a new medical treatment is associated with patient recovery, or whether political preference varies by geographic region, they are working with categorical variables — variables whose values represent group memberships or qualitative labels rather than ordered numerical quantities. The development of rigorous methods for cross-classifying such variables and testing for association between them transformed fields ranging from epidemiology to social science, enabling researchers to move beyond anecdotal evidence toward data-driven conclusions.
1900 • Pearson's Chi-Square Test
1922 • Fisher and Contingency Tables
1950s • Simpson's Paradox Formalized
1977 • Exploratory Data Analysis Movement
The central question that this topic addresses is deceptively simple: Is there a relationship between two categorical variables, or are they independent? Answering this question requires organizing data into a structured format, computing appropriate proportions, and interpreting patterns in a way that distinguishes genuine association from coincidence. These skills form a core component of the AP Statistics curriculum and appear repeatedly in both multiple-choice and free-response sections of the exam.
SECTION 2
Core Principles & Definitions
Before diving into computations, it is essential to establish a precise vocabulary. A two-way table (also called a contingency table) cross-classifies individuals according to two categorical variables simultaneously — one variable defines the rows and the other defines the columns. Each cell in the table contains a count (or frequency) of individuals who belong to the corresponding combination of categories. The row and column totals, often called marginal frequencies, summarize the overall distribution of each variable, while the individual cell counts are the joint frequencies.
Marginal Distribution
Joint Distribution
Conditional Distribution
Association vs. Independence
KEY TAKEAWAY
SECTION 3
Visual Explanation — Reading a Two-Way Table
The most natural visual representation of categorical cross-classification is the two-way table itself, augmented with marginal totals. The diagram below shows a survey of 400 college students classified by class year (Freshman, Sophomore, Junior, Senior) and preferred study location (Library, Dorm Room, Coffee Shop). Study the structure carefully: the joint frequencies fill the interior cells, the marginal frequencies appear along the right edge and bottom edge, and the grand total sits in the lower-right corner.
Notice that each row total (100 for every class year in this balanced example) is obtained by summing across the three study-location cells in that row. Likewise, each column total (160 for Library, 140 for Dorm Room, 100 for Coffee Shop) is the sum of the four class-year cells in that column. The grand total, 400, can be computed either by summing the row totals or the column totals — a useful consistency check. When you convert joint frequencies to proportions by dividing each cell by 400, you obtain the joint relative frequency distribution; when you divide each cell by its row total, you obtain the conditional distribution of study location given class year. These conditional distributions are the primary tool for assessing association.
SECTION 4
Mathematical Framework
Three types of proportions arise from a two-way table, and distinguishing among them is essential for accurate interpretation. Let nij denote the count in row i and column j, let ni• denote the total for row i, let n•j denote the total for column j, and let n denote the grand total.
JOINT RELATIVE FREQUENCY
Dividing a cell count by the grand total gives the proportion of all individuals who fall in that particular cell. The sum of all joint relative frequencies equals 1.
MARGINAL RELATIVE FREQUENCY
Dividing a row total or column total by the grand total gives the overall proportion of individuals in that category. These proportions describe each variable separately.
CONDITIONAL RELATIVE FREQUENCY
Dividing a cell count by its row total gives the proportion of individuals in row i who are in column j. Analogously, dividing by the column total yields p̂(row i | column j).
EXPECTED COUNT UNDER INDEPENDENCE
If two variables were truly independent, the expected count in cell (i, j) would equal the row total times the column total divided by the grand total. Comparing observed and expected counts is the basis of the chi-square test, which is studied in greater depth later in the course.
The distinction between joint, marginal, and conditional proportions is a frequent source of error on the AP exam. A common mistake is to compute a conditional proportion but divide by the grand total instead of the appropriate row or column total. Always ask yourself: what group am I conditioning on? The denominator of a conditional proportion is always the size of that conditioning group, not the size of the entire sample.
SECTION 5
Conditional Distributions & Segmented Bar Charts
The most powerful way to investigate whether two categorical variables are associated is to compare conditional distributions side by side. If the conditional distribution of the column variable looks roughly the same across every row, the variables appear independent. If the distributions differ noticeably, there is evidence of an association. A segmented (stacked) bar chart is the standard graphical tool for this comparison: each bar represents one category of the explanatory variable and is divided into colored segments whose lengths correspond to the conditional proportions of the response variable.
The chart above makes the association visually striking. If class year and study location were independent, every bar would have identical segment proportions — the cyan, violet, and pink bands would be at the same heights across all four bars. Instead, the Library segment grows steadily from Freshman (0.30) to Senior (0.50), while the Dorm Room segment shrinks from 0.50 to 0.20. The Coffee Shop segment fluctuates modestly. These differing conditional distributions provide strong descriptive evidence of association. On the AP exam, a segmented bar chart is the preferred graphic for displaying conditional distributions, and your written interpretation should always explicitly compare the conditional proportions across groups.
AP EXAM TIP
SECTION 6
Worked Example
A researcher surveyed 500 adults and classified each by exercise frequency (Regular or Irregular) and health self-rating (Excellent, Good, Fair). The two-way table is shown below. Determine the conditional distribution of health self-rating for each exercise group, and assess whether the data suggest an association between exercise frequency and health self-rating.
| Excellent | Good | Fair | Total | |
|---|---|---|---|---|
| Regular | 90 | 120 | 40 | 250 |
| Irregular | 30 | 100 | 120 | 250 |
| Total | 120 | 220 | 160 | 500 |
Exercise Frequency × Health Self-Rating (n = 500)
Computing & Comparing Conditional Distributions
- 1
Step 1 — Identify the conditioning variable
We want the conditional distribution of health self-rating given exercise frequency. This means we condition on the rows. Each row total (250 for Regular, 250 for Irregular) will serve as the denominator. - 2
Step 2 — Compute conditional proportions for Regular exercisers
P̂(Excellent | Regular) = 90 / 250 = 0.36, P̂(Good | Regular) = 120 / 250 = 0.48, P̂(Fair | Regular) = 40 / 250 = 0.16. Note that these three proportions sum to 1.00.Regular: 0.36 Excellent, 0.48 Good, 0.16 Fair - 3
Step 3 — Compute conditional proportions for Irregular exercisers
P̂(Excellent | Irregular) = 30 / 250 = 0.12, P̂(Good | Irregular) = 100 / 250 = 0.40, P̂(Fair | Irregular) = 120 / 250 = 0.48. Again, these sum to 1.00.Irregular: 0.12 Excellent, 0.40 Good, 0.48 Fair - 4
Step 4 — Compare and interpret
The conditional distributions differ substantially. Among Regular exercisers, 36% rated their health as Excellent, compared to only 12% of Irregular exercisers. Conversely, only 16% of Regular exercisers rated their health as Fair, compared to 48% of Irregular exercisers. Because the conditional distributions of health self-rating differ markedly between the two exercise groups, the data suggest an association between exercise frequency and health self-rating. Regular exercisers tend to report higher health ratings.Conclusion: There is an association. However, because this is an observational study, we cannot conclude that exercise causes better health self-ratings.
SECTION 7
Strengths, Limitations & Common Pitfalls
| Aspect | Strength | Limitation / Pitfall |
|---|---|---|
| Simplicity | Two-way tables are easy to construct and interpret, requiring no assumptions about distributions. | They can become unwieldy when one or both variables have many categories, making patterns hard to spot. |
| Detecting Association | Comparing conditional distributions provides a clear, intuitive method for identifying association. | Descriptive comparison alone cannot quantify the strength of association or determine statistical significance. |
| Causation | The table correctly displays the data, allowing the reader to see what the evidence shows. | Association ≠ causation. Lurking or confounding variables may explain an apparent relationship. |
| Simpson's Paradox | Awareness of this paradox encourages analysts to stratify data by potential confounders. | Aggregated data can reverse the direction of an association when a lurking variable is ignored. |
| Graphical Display | Segmented bar charts and mosaic plots make conditional distributions visually comparable. | Choosing the wrong denominator (joint instead of conditional) can produce misleading charts. |
Strengths and limitations of two-way table analysis
SIMPSON'S PARADOX WARNING
SECTION 8
Connection to the Chi-Square Test & Beyond
The descriptive techniques covered in this lesson — constructing two-way tables, computing conditional distributions, and identifying association through graphical comparison — are foundational. Later in the AP Statistics course, you will formalize the assessment of association using the chi-square test for independence (or for homogeneity, depending on the study design). That inferential procedure uses the expected counts under independence (Eij = ni• × n•j / n) and compares them to the observed counts via a test statistic that follows an approximate chi-square distribution.
| Feature | Descriptive Analysis (This Lesson) | Chi-Square Inference (Later) |
|---|---|---|
| Goal | Describe and visualize patterns in the sample data | Determine whether observed association is statistically significant |
| Method | Conditional proportions, segmented bar charts | χ² test statistic, p-value, degrees of freedom |
| Conclusion type | Association appears to exist (or not) based on descriptive evidence | Reject or fail to reject H₀ of independence at a specified significance level |
| Prerequisites | None beyond data organization | Random sampling/assignment, expected counts ≥ 5 |
Descriptive vs. inferential analysis of two categorical variables
The descriptive skills from this lesson are not rendered obsolete by inferential methods; rather, they remain an indispensable first step. On the AP exam, free-response questions about two categorical variables almost always require students to compute and compare conditional distributions before (or even instead of) performing a formal hypothesis test. A thorough descriptive analysis also helps you understand how the variables are associated — something a p-value alone cannot tell you.
SECTION 9
Practice Problems
Question 1: CONCEPTUAL
- A. The number of males who prefer dogs equals the number of females who prefer dogs.
- B. The joint relative frequency of each cell equals zero.
- C. The conditional distribution of pet preference is the same for males and females.
- D. The marginal distribution of gender is the same as the marginal distribution of pet preference.
- E. Each cell count is exactly equal to every other cell count.
Show answer (C)
Question 2: BASIC CALCULATION
- A. 0.20
- B. 1/3 ≈ 0.333
- C. 0.40
- D. 0.50
- E. 0.60
Show answer (B)
Question 3: INTERMEDIATE
- A. There is no association because bus is the most common transportation method at every school level.
- B. There is an association because 50% of Elementary students ride the bus compared to only 20% of High school students.
- C. The variables are independent because each school level has exactly three transportation options.
- D. The marginal distribution shows that walking is equally popular at all levels.
- E. There is an association because the grand total (800) is not evenly divisible by the number of cells (9).
Show answer (B)
Question 4: APPLIED
4 ptsShow answer
Question 5: CRITICAL THINKING
4 ptsShow answer
SUMMARY
Summary
Summary
Analyzing the relationship between two categorical variables begins with organizing data into a two-way table (contingency table) that displays joint frequencies in the interior cells and marginal frequencies along the edges. The marginal distribution of a single variable is obtained by dividing its marginal frequencies by the grand total, while the conditional distribution of one variable given a specific value of the other is obtained by dividing cell counts by the appropriate row or column total.
Two variables exhibit association when their conditional distributions differ across categories; they are independent when the conditional distributions are approximately equal. Segmented bar charts are the preferred graphical tool for comparing conditional distributions side by side. Always cite specific proportions when describing association, always use the correct denominator (the conditioning group's total), and always remain vigilant for Simpson's Paradox — a reversal of association that occurs when a lurking variable confounds the aggregated analysis. Association does not imply causation; causal conclusions require a well-designed randomized experiment.