# Summary Statistics for Two Categorical Variables

> AP Statistics · AP 2024-2026 Statistics
> Source: https://www.owlsprep.com/study/ap-statistics-u11-summary-statistics-for-two-categorical/

We cover two-way contingency table structure, calculation of all three relative frequency types, detection of categorical association, and AP-aligned segmented bar chart construction.

**Prerequisites:** [Calculate and interpret relative frequency for single categorical variables](https://www.owlsprep.com/study/ap-statistics-u10-single-categorical-summary-stats/); [Interpret univariate bar charts for categorical data](https://www.owlsprep.com/study/ap-statistics-u9-univariate-categorical-visualizations/)

## Learning objectives

- Calculate joint, marginal, and conditional relative frequencies from raw two-way contingency tables
- Identify statistically meaningful association between two categorical variables using relative frequency comparisons
- Construct fully labeled segmented bar charts to visualize relationships between two categorical variables
- Select the correct summary statistic to answer context-specific AP exam research questions

## Structure of Two-Way Contingency Tables

A two-way contingency table organizes raw count data for observations classified by two separate categorical variables. Rows represent categories of the first variable, columns represent categories of the second variable, and each cell stores the number of observations that fall into the paired row and column category.

**Two-way contingency table** — A tabular summary of raw counts for all cross-classified category pairs from two categorical variables, including row, column, and grand total sums.

*Example:* A table tracking 200 student survey responses, with rows for 'pass/fail' exam outcome and columns for 'studied less than 5 hours / studied 5+ hours'.

**Worked example:** A school records 120 total students: 40 9th graders who play sports, 30 9th graders who do not play sports, 25 10th graders who play sports, 25 10th graders who do not play sports. Construct the full two-way contingency table including all totals.

1. Define rows as grade level (9th, 10th) and columns as sports participation (play, do not play)
2. Populate raw count cells with the given values
3. Calculate row totals: 70 total 9th graders, 50 total 10th graders
4. Calculate column totals: 65 total sports players, 55 total non-players
5. Confirm grand total sum equals 120, matching the total student count

**Check your understanding**

Test your understanding of table structure:

1. What value should the sum of all individual cell counts equal?

   - Sum of all row totals
   - Grand total sample size
   - Sum of all column totals
   - All of the above

   *Why:* All three values are mathematically identical for a properly constructed two-way table.

## Calculating Joint, Marginal, and Conditional Relative Frequencies

All three relative frequency types use raw counts from the two-way table, but differ in the denominator used for calculation. The denominator is the key detail AP graders check for full credit on calculation questions.

| Frequency Type | Denominator | Example Calculation |
| --- | --- | --- |
| Joint | Grand total sample size | Number of 9th graders who play sports / 120 total students |
| Marginal | Grand total sample size | Total number of sports players / 120 total students |
| Conditional | Subgroup total size | Number of sports players / 70 total 9th graders |

**Worked example:** Using the 120-student two-way table from the prior example, calculate the joint relative frequency for 10th graders who do not play sports, the marginal relative frequency for 9th graders, and the conditional relative frequency of playing sports given the student is in 10th grade.

1. Joint relative frequency: 25 non-playing 10th graders / 120 total students = 0.208, or 20.8%
2. Marginal relative frequency for 9th graders: 70 total 9th graders / 120 total students = 0.583, or 58.3%
3. Conditional relative frequency of playing sports for 10th graders: 25 playing 10th graders / 50 total 10th graders = 0.5, or 50%

## Detecting Association Between Two Categorical Variables

Two categorical variables have no association (are independent) if the conditional relative frequency of one variable is identical across all categories of the second variable. If conditional frequencies differ by a meaningful margin, the variables are associated.

**Worked example:** For our student dataset, the conditional relative frequency of playing sports for 9th graders is 40/70 = 57.1%, and for 10th graders it is 50%. Is there evidence of association between grade level and sports participation?

1. Compare the two conditional relative frequencies directly: 57.1% vs 50%
2. Note that the proportion of students playing sports is 7.1 percentage points higher for 9th graders than 10th graders
3. Conclude that there is observed association between grade level and sports participation in this sample

> **Critical AP Warning**
>
> Never claim association based on raw count differences alone. Always convert counts to relative frequencies first, especially when comparing subgroups of unequal total size.

> **Exam tip:** AP exam association questions almost always require you to compare two conditional relative frequencies explicitly, not just state a trend.

## Visualizing Relationships with Segmented Bar Charts

Segmented bar charts (also called stacked bar charts) use bars of equal total height, split into colored segments proportional to conditional relative frequencies, to make association easy to visualize. For no association, every bar will have identical segment proportions.

**Exam command terms**

Common AP exam command terms for this task:

- **Construct a segmented bar chart** — You must draw bars of equal 100% total height, label both axes, add a legend for segments, and label all category groups *(2021 AP Stats FRQ 3 part c)*

**Worked example:** Outline the steps to draw a segmented bar chart for our grade level and sports participation dataset

1. Draw two equal height bars, one labeled '9th Grade' and one labeled '10th Grade' on the x-axis
2. Label the y-axis 'Relative Frequency' with a scale from 0 to 1
3. Split the 9th grade bar 57.1% / 42.9% for sports players / non-players
4. Split the 10th grade bar 50% / 50% for sports players / non-players
5. Add a legend assigning distinct colors to 'Play Sports' and 'Do Not Play Sports'

## Common pitfalls

- **Wrong:** Using the grand total sample size as the denominator for conditional relative frequency calculations
  - Why it fails: This produces a joint frequency value instead of the requested conditional value, leading to zero points for the calculation on AP FRQs
  - Correct: Explicitly identify the restricted subgroup before selecting your denominator for conditional frequency problems
- **Wrong:** Using raw counts instead of relative frequencies to compare subgroups of unequal size
  - Why it fails: Larger subgroups will always have higher raw counts, leading to false conclusions about association
  - Correct: Convert all counts to relative frequencies before making any cross-group comparison
- **Wrong:** Claiming no association exists just because conditional frequencies are not perfectly identical
  - Why it fails: Small differences from random sampling variation are expected even for independent variables
  - Correct: Note that perfect independence requires 100% identical conditional frequencies, and only claim association if differences are large enough to be meaningful
- **Wrong:** Drawing segmented bars of unequal total height
  - Why it fails: AP graders deduct a full scoring point for this error, as unequal heights distort proportional comparisons
  - Correct: Set all bars to a total height of 1 (100%) to represent full conditional relative frequency distributions
- **Wrong:** Concluding a causal relationship between two associated categorical variables
  - Why it fails: Observational two-way table data cannot rule out unmeasured confounding variables
  - Correct: Only state that observed association exists, and never claim causation unless the data comes from a randomized controlled experiment

## Cheatsheet

| Statistic Type | Denominator | Core Use Case |
| --- | --- | --- |
| Joint Relative Frequency | Grand total sample size | Share of observations in one specific cross-category pair |
| Marginal Relative Frequency | Grand total sample size | Share of observations in one single variable category |
| Conditional Relative Frequency | Restricted subgroup total | Share of observations in a target group given a pre-defined condition |

## What's next

Mastering two categorical variable summary statistics is the critical foundation for your upcoming unit on chi-square inference tests, the most heavily tested hypothesis procedure for categorical data on the AP Stats exam. You will reuse the exact relative frequency calculation skills you learned here to compute expected counts for chi-square goodness of fit, chi-square test for independence, and chi-square test for homogeneity problems, all of which carry significant point weight on both the multiple choice and free response sections. You will also build on this knowledge to identify Simpson’s paradox, a famous statistical anomaly where observed association trends reverse when a third confounding categorical variable is added to the two-way table. Continue your progress with the linked resources below.

---

From [OwlsPrep](https://www.owlsprep.com) — free study guides for A-Level, IB, AP and IGCSE, written against the official syllabus. Canonical page: https://www.owlsprep.com/study/ap-statistics-u11-summary-statistics-for-two-categorical/
