Course contentsShow
← Mathematics
Lesson 3044 of 3,12159. Statistics — Descriptive and InferentialFree lesson

Chi-Squared Test for Independence

Assess whether two categorical variables are independent using contingency tables and the chi-squared test.

Chi-Squared Test for Independence

What you'll learn: You'll learn how to determine whether two categorical variables are related or independent using contingency tables and the chi-squared test.

The Core Idea

Imagine you want to know if there's a relationship between two categorical factors—say, whether someone's favorite type of exercise (running, swimming, cycling) is related to their age group (young, middle-aged, senior). The chi-squared test for independence helps you decide whether observed patterns in your data represent real associations or just random chance.

The test compares what you actually observe in your data against what you'd expect to see if the two variables were completely independent (unrelated). If the difference is large enough, you conclude the variables are associated.

How It Works

You organize your data in a contingency table (a two-way frequency table) showing counts for each combination of categories. For example:

RunningSwimmingCyclingTotal
Young30202575
Senior10301555
Total405040130

The Test Statistic

For each cell, calculate the expected count assuming independence: Expected = (Row Total × Column Total) / Grand Total

Then compute the chi-squared statistic: χ² = Σ [(Observed - Expected)² / Expected]

Compare this to the chi-squared distribution with degrees of freedom = (rows - 1) × (columns - 1). A large χ² value (small p-value) suggests the variables are not independent.

When to Use It

  • Both variables are categorical
  • Observations are independent
  • Expected counts in each cell should be at least 5

Key Takeaway: The chi-squared test for independence uses contingency tables to assess whether two categorical variables are associated by comparing observed frequencies to those expected under independence.