01 / 20
\(\chi^2\)

Chi-Square
Goodness-of-Fit

Learn how to test whether observed data matches an expected distribution using the \(\chi^2\) statistic.

College Statistics

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?

One Variable
You have a single categorical variable with two or more categories.
Count Data
Your data are counts (frequencies) of observations in each category.
Known Model
You have a specific expected distribution to test against (e.g., equal proportions).

Observed vs. Expected

0 10 20 30 40 Red Blue Green Yellow Orange 25 25 25 25 25 35 25 20 30 15 Expected Observed

Setting Up Hypotheses

\(H_0\) : Null
The data follow the specified distribution. Observed differences from expected are due to random chance.
\(H_a\) : Alternative
The data do not follow the specified distribution. At least one category proportion differs.

The \(\chi^2\) Test Statistic

1
\(O_i\) : the observed count in category \(i\).
2
\(E_i\) : the expected count in category \(i\) under \(H_0\).
3
\(\sum\) : sum over all \(k\) categories.

The \(\chi^2\) Distribution

0 5 10 15 20 \(\chi^2\) value df = 3 df = 6 df = 10

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

1
Random sample: The data must come from a random sample or random process.
2
Independence: Observations must be independent. If sampling without replacement, the sample should be < 10% of the population.
3
Large counts: All expected counts must satisfy \(E_i \geq 5\). This ensures the \(\chi^2\) approximation is valid.

How to Apply the Test

1
State hypotheses: Write \(H_0\) (data follows the model) and \(H_a\) (data does not follow the model).
2
Check conditions: Random, independent, and all \(E_i \geq 5\).
3
Calculate expected counts: \(E_i = n \times p_i\), where \(n\) is total sample size and \(p_i\) is the hypothesized proportion.
4
Compute \(\chi^2\): Use \(\chi^2 = \sum \frac{(O_i - E_i)^2}{E_i}\).
5
Find the p-value: Use the \(\chi^2\) distribution with \(\text{df} = k - 1\). Compare to significance level \(\alpha\).
6
State conclusion: If \(p\text{-value} < \alpha\), reject \(H_0\). Otherwise, fail to reject \(H_0\).

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}\)
125201.25
217200.45
315201.25
423200.45
524200.80
616200.80

Example 1: Conclusion

1
Degrees of freedom: \(\text{df} = 6 - 1 = 5\).
2
p-value: \(P(\chi^2 \geq 5.00) \approx 0.416\) (from the \(\chi^2\) table with df = 5).
3
Decision at \(\alpha = 0.05\): Since \(0.416 > 0.05\), we fail to reject \(H_0\).

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)100901.111
B (3/16)24301.200
C (3/16)26300.533
D (1/16)10100.000

Example 2: Result

df
\(k - 1 = 4 - 1 = 3\)
p-value
\(P(\chi^2 \geq 2.844) \approx 0.416\)
Decision
\(0.416 > 0.05\): Fail to reject \(H_0\)

Interpreting the p-value

Critical value
\(\chi^2 = 5.0\)
0 5 11.07 Reject \(H_0\) Fail to reject
\(\chi^2\) distribution, df = 5, \(\alpha = 0.05\)

Common Mistakes

✕ Using Proportions Instead of Counts
The formula requires counts (frequencies), not proportions or percentages. Always multiply proportions by \(n\).
✕ Checking Observed Instead of Expected
The Large Counts condition applies to expected counts (\(E_i \geq 5\)), not observed counts.
✕ Wrong Degrees of Freedom
For GOF, \(\text{df} = k - 1\), where \(k\) is the number of categories. Do not use \(n - 1\) or \((r-1)(c-1)\).

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?