Skip to main content
Back to Guides
Advanced19 min read

Chi-Square Tests Complete Guide

Test independence, goodness of fit, and analyze categorical data relationships with chi-square analysis.

Ready to calculate?

Try our Chi-Square Calculator

Open Calculator

Introduction

The chi-square test is a statistical method for analyzing categorical (nominal) data. It determines whether there's a significant relationship between categorical variables or whether observed frequencies differ from expected frequencies.

Types of Chi-Square Tests

Test of Independence

Tests whether two categorical variables are independent.

Example: Is gender related to voting preference?

Goodness of Fit

Tests whether observed frequencies match expected frequencies.

Example: Does a die roll follow a uniform distribution?

Test of Independence

Hypotheses

H₀ (Null):

Variables are independent (no relationship)

H₁ (Alternative):

Variables are dependent (there is a relationship)

Expected Frequencies

Formula

E = (Row Total × Column Total) / Grand Total

Expected frequencies represent what we'd expect if the variables were truly independent.

Calculation Steps

Chi-Square Statistic

χ² = Σ [(O - E)² / E]

Where O = observed frequency, E = expected frequency

Steps

  1. Create contingency table with observed frequencies
  2. Calculate row and column totals
  3. Compute expected frequencies for each cell
  4. Calculate (O-E)²/E for each cell
  5. Sum all values to get χ²
  6. Find degrees of freedom: df = (rows-1)(columns-1)
  7. Compare to critical value or find p-value

Interpretation

p-value < 0.05

Reject H₀. Variables are likely dependent. There is a significant relationship.

p-value ≥ 0.05

Fail to reject H₀. Insufficient evidence of relationship.

Summary

Key Takeaways

  • 1.Chi-square tests analyze categorical data relationships.
  • 2.Test of independence compares observed vs expected frequencies.
  • 3.χ² = Σ(O-E)²/E
  • 4.Degrees of freedom = (rows-1)(columns-1)