Course contentsShow
← Data Science
Lesson 423 of 2,14511. Hypothesis Tests for Proportions and CategoriesFree lesson

Contingency Tables and Expected Frequencies

Understand how to construct contingency tables and calculate expected frequencies under independence assumption.

Contingency Tables and Expected Frequencies

What You'll Learn

You'll learn how to organize categorical data into contingency tables and calculate the frequencies you'd expect if two variables were completely independent of each other.

What is a Contingency Table?

A contingency table (also called a cross-tabulation or two-way table) displays the frequency distribution of two categorical variables simultaneously. Think of it like a scoreboard showing how often different combinations occur.

For example, imagine surveying 200 people about their coffee preference (Regular/Decaf) and exercise habits (Yes/No). Your contingency table might look like:

ExercisesDoesn't ExerciseRow Total
Regular8040120
Decaf305080
Column Total11090200

These are your observed frequencies — what actually happened in your data.

Calculating Expected Frequencies

Expected frequencies represent what you'd expect to see if the two variables were completely independent (no relationship). They're calculated using this formula:

Expected Frequency = (Row Total × Column Total) / Grand Total

For the "Regular Coffee + Exercises" cell:

  • Expected = (120 × 110) / 200 = 66

This means if coffee choice and exercise were independent, you'd expect about 66 people in that category, not the 80 you observed.

You calculate expected frequencies for every cell in the table. These become the benchmark for testing independence: large differences between observed and expected suggest the variables might be related.

Key Takeaway: Contingency tables organize bivariate categorical data, and expected frequencies (calculated assuming independence) serve as the null hypothesis baseline for testing whether two categorical variables are truly related.