
Definition: A chi-square test compares observed counts with expected counts in categorical data to judge whether a distribution fits or two variables are associated.
What does the test do?
The statistic is χ2 = sum of (observed – expected)2 / expected. Large values mean the observed counts depart from what H0 predicts. The version for one categorical variable is the goodness-of-fit test, with df = number of categories – 1.
How does one run?
Worked example: a die is rolled 60 times, so each face is expected 10 times. Observed counts: 8, 12, 9, 14, 5, 12.
- Terms: 4/10, 4/10, 1/10, 16/10, 25/10, 4/10
- Total: χ2 = 54/10 = 5.4
- df = 5, and the 0.05 critical value is 11.07
Since 5.4 is below 11.07, we fail to reject H0: the counts are consistent with a fair die.
What goes wrong?
Using percentages instead of counts, or expected counts below 5, which break the conditions. Mathbot also warns that the test says nothing about the direction of any difference.
