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

The Chi-Squared Test Statistic

Learn how to calculate the chi-squared statistic by comparing observed and expected frequencies across cells.

The Chi-Squared Test Statistic

You'll learn how to calculate the chi-squared statistic to measure how far your observed data diverges from what you expected.

The Core Idea

The chi-squared test statistic is a single number that summarizes how much your observed frequencies differ from your expected frequencies across all cells in a contingency table (or any categorical data table). The bigger this number, the more your data deviates from what you'd expect under the null hypothesis.

Think of it like a "disagreement score" between reality and expectation. If observed and expected values match perfectly, the statistic equals zero. The more they differ, the larger the statistic grows.

The Formula

The chi-squared statistic (χ²) is calculated as:

χ² = Σ [(Observed - Expected)² / Expected]

For each cell in your table:

  1. Subtract the expected frequency from the observed frequency
  2. Square that difference (so negatives don't cancel positives)
  3. Divide by the expected frequency (to standardize the contribution)
  4. Sum up all these values across every cell

Why Divide by Expected?

Dividing by the expected frequency ensures fairness. A difference of 10 matters more when you expected 20 (50% off!) than when you expected 200 (only 5% off). This standardization puts all cells on equal footing.

Example

If one cell has Observed = 45 and Expected = 50:

  • Contribution = (45 - 50)² / 50 = 25 / 50 = 0.5

Do this for all cells and add them up to get your χ² test statistic.

Key Takeaway: The chi-squared test statistic quantifies the total disagreement between observed and expected frequencies by summing squared, standardized differences across all cells—larger values indicate greater evidence against the null hypothesis.