Chi-Square
Goodness-of-Fit
Learn how to test whether observed data matches an expected distribution using the \(\chi^2\) statistic.
What Is the \(\chi^2\) Goodness-of-Fit Test?
The Chi-Square Goodness-of-Fit test determines whether a categorical variable follows a hypothesized distribution. It compares observed counts from a sample against expected counts under a specific model.
When Do We Use It?
Observed vs. Expected
Setting Up Hypotheses
The \(\chi^2\) Test Statistic
The \(\chi^2\) Distribution
Goodness-of-Fit vs. Test of Independence
| Goodness-of-Fit | Test of Independence | |
|---|---|---|
| Variables | One categorical variable | Two categorical variables |
| Question | Does the distribution match a model? | Are two variables associated? |
| Data Format | One-way frequency table | Two-way contingency table |
| df | \(k - 1\) | \((r-1)(c-1)\) |
| Example | Equal candy colors? | Is gender linked to preference? |
Checking Conditions
How to Apply the Test
Example 1: Fair Die?
A die is rolled 120 times. Under the null hypothesis, each face is equally likely with \(p = \frac{1}{6}\). The expected count for each face is \(E = 120 \times \frac{1}{6} = 20\).
| Face | \(O_i\) | \(E_i\) | \(\frac{(O-E)^2}{E}\) |
|---|---|---|---|
| 1 | 25 | 20 | 1.25 |
| 2 | 17 | 20 | 0.45 |
| 3 | 15 | 20 | 1.25 |
| 4 | 23 | 20 | 0.45 |
| 5 | 24 | 20 | 0.80 |
| 6 | 16 | 20 | 0.80 |
Example 1: Conclusion
Example 2: Genetic Ratios
A Mendelian genetics model predicts offspring in a 9:3:3:1 ratio across four phenotypes. A biologist observes 160 offspring.
| Phenotype | \(O_i\) | \(E_i\) | \(\frac{(O-E)^2}{E}\) |
|---|---|---|---|
| A (9/16) | 100 | 90 | 1.111 |
| B (3/16) | 24 | 30 | 1.200 |
| C (3/16) | 26 | 30 | 0.533 |
| D (1/16) | 10 | 10 | 0.000 |
Example 2: Result
Interpreting the p-value
Common Mistakes
Question 1 of 5
A survey of 200 people asks for their favorite season. Under the null hypothesis, each of the 4 seasons is equally preferred. What is the expected count for each category?
Question 2 of 5
A \(\chi^2\) goodness-of-fit test has 6 categories. What are the degrees of freedom?
Question 3 of 5
Which condition must be checked for the \(\chi^2\) goodness-of-fit test to be valid?
Question 4 of 5
A researcher calculates \(\chi^2 = 12.4\) with \(\text{df} = 3\) and finds \(p = 0.006\). At \(\alpha = 0.05\), what is the correct conclusion?
Question 5 of 5
For a category with \(O_i = 18\) and \(E_i = 25\), what is the contribution to the \(\chi^2\) statistic?