Chi-square goodness-of-fit test
Do the observed counts of one categorical variable match prespecified hypothesized proportions?
Adjust survey results
Observed category counts
Sliders range from 0 to 110 people. Number fields can also display or accept larger counts.
Does the observed distribution of one categorical variable match the hypothesized distribution?
A school hypothesizes in advance that the proportions of students using three learning devices are 50%, 30%, and 20%. After randomly surveying students, do the observed counts deviate from these proportions beyond sampling variability?
H₁: In the population, at least one category proportion differs from its hypothesized proportion.
Adjust survey results
Total number of people n=100; hypothesized proportions under H₀: 50.0%, 30.0%, 20.0%.
Observed and expected counts
Bars show observed counts O; horizontal lines mark expected counts E calculated using the current sample size. Both update together when you drag the counts.
Adjust survey results
Observed category counts
Sliders range from 0 to 110 people. Number fields can also display or accept larger counts.
Expected counts E: hypothesized proportions times the observed sample size
Both the goodness-of-fit test and the test of independence in Lesson 03 compare O with E, but their expected counts come from different sources: here they come directly from the category proportions specified by H₀.
| Category | Hypothesized proportion | O | E=n×p |
|---|---|---|---|
| Laptop | 50.0% | 56 | 50.00 |
| Tablet | 30.0% | 27 | 30.00 |
| Phone | 20.0% | 17 | 20.00 |
| Grand total | 100% | 100 | 100.00 |
Substitute values term by term
- E1 = 100 × 0.5000 = 50.00 (Laptop)
- E2 = 100 × 0.3000 = 30.00 (Tablet)
- E3 = 100 × 0.2000 = 20.00 (Phone)
Note: a goodness-of-fit test does not require equal sample counts in all categories. It compares observed counts with the proportions specified by H₀.
Adjust survey results
Observed category counts
Sliders range from 0 to 110 people. Number fields can also display or accept larger counts.
The χ² statistic: sum each category's deviation from its hypothesized expectation
Break down the statistic by category
| Category | Hypothesized proportion | O | E=n×p | (O−E)²/E |
|---|---|---|---|---|
| Laptop | 50.0% | 56 | 50.00 | 0.720 |
| Tablet | 30.0% | 27 | 30.00 | 0.300 |
| Phone | 20.0% | 17 | 20.00 | 0.450 |
| Grand total | 100% | 100 | 100.00 | 1.470 |
From numerical substitution to the final result
- Category 1: (56 − 50.00)² / 50.00 ≈ 0.720
- Category 2: (27 − 30.00)² / 30.00 ≈ 0.300
- Category 3: (17 − 20.00)² / 20.00 ≈ 0.450
- χ² = 0.720 + 0.300 + 0.450 ≈ 1.470
Adjust survey results
Degrees of freedom for this test: 2
Degrees of freedom determine the χ² curve's shape; larger χ² values fall in the right tail
For a goodness-of-fit test with k categories, prespecified hypothesized proportions, and no parameters estimated from the sample, the degrees of freedom are df=k−1. Thus, three categories give df=2 and four give df=3.
- χ² distribution (df=2)
- Right-tail p-value
- Critical value
The curve is the currently displayed χ² density. For this test, shading is the area to the right of the observed χ² statistic (the p-value); the critical line marks the critical value.
P ≥ α=0.05. Fail to reject H₀.
Compare curve shapes only (without changing this test)
The displayed curve matches this test: df=2, χ²=1.470.
Adjust survey results
Observed category counts
Sliders range from 0 to 110 people. Number fields can also display or accept larger counts.
Complete a goodness-of-fit test in five steps and check its conditions
First specify the hypothesized proportions, then collect a sample, calculate χ², and find the right-tail p-value. Finally, check whether the χ² approximation can be used for a statistical decision.
| Category | Hypothesized proportion | O | E=n×p | (O−E)²/E |
|---|---|---|---|---|
| Laptop | 50.0% | 56 | 50.00 | 0.720 |
| Tablet | 30.0% | 27 | 30.00 | 0.300 |
| Phone | 20.0% | 17 | 20.00 | 0.450 |
| Grand total | 100% | 100 | 100.00 | 1.470 |
H₀: category proportions are 50.0%, 30.0%, 20.0%; H₁: at least one category proportion differs.
n=100; expected counts E in category order: 50.00, 30.00, 20.00; df=3−1=2.
Right-tail p-value 0.4795; α=0.05; critical value≈5.991.
Fail to reject H₀. There is insufficient evidence against the prespecified population category proportions. This does not prove that the hypothesized proportions are exactly correct.
⑤ Conditions for use and research interpretation
Each student is counted in only one mutually exclusive category. Researchers must assess independence and sampling from the design; the program cannot verify them automatically.
Every observation belongs to one and only one category. Hypothesized proportions should be specified in advance and sum to 100%.
This lesson uses a conservative classroom rule of thumb: expected count ≥5 in every category. Current minimum expected count: 20.00.
All expected counts are ≥5, meeting this lesson's rule of thumb. Sampling and independence still need to be checked.
If the hypothesized proportions contain parameters estimated from the same data, the number of estimated parameters may need to be subtracted from the degrees of freedom; df=k−1 cannot be applied directly. If expected counts are too small, consider combining categories on theoretical grounds, increasing the sample size, or using exact/simulation methods. Do not combine categories arbitrarily after seeing the data to obtain significance.