Skip to main content
StatPlay Topics Chi-Squared Test

Chi-Squared Test — Goodness-of-Fit & Independence

Test whether a die is fair (goodness-of-fit) or whether two categorical variables are independent. Visualize how observed-vs-expected deviations accumulate into a χ² statistic and see the rejection region in real time.

I.06 / CHI-SQUARED TEST

Chi-Squared Test

So far we've tested means. But some data is purely categorical — survey choices, dice outcomes, disease × smoking. The chi-squared test quantifies "deviation from expectation" for these counts. The bigger the mismatch, the brighter the χ² statistic glows.

Goodness-of-fit asks: "Does the observed category distribution match a theoretical one?" Classic example: is the die fair?
Test of independence asks: "Are two categorical variables independent?" Compute χ² = Σ (O−E)²/E across every cell of the contingency table.
Why divide by E? → A deviation of 2 from an expected 10 matters more than 2 from an expected 1,000. Dividing by E turns raw gaps into relative ones.
Both use a χ²-distributed statistic; the p-value is the right-tail area. df = k−1 for goodness-of-fit, (r−1)(c−1) for independence.

▶ ① Goodness-of-Fit — Is the Die Fair?

🎲 Click a bar on the left to add one roll (Shift+click to subtract)
Threshold for rejecting H₀. 0.05 = "if this would happen less than 5% by chance, it's not random."
Rolls n 0
Test statistic χ²
df
p-value
Decision

▶ ② Test of Independence — Are Two Variables Independent?

Click a cell on the left to add +1 (Shift+click for −1)
Significance level for the independence test. Smaller = more conservative.
Total n 0
Test statistic χ²
df
p-value
Decision
UP NEXT —catching a relationship with a line M.01 Simple Regression