Chi-Square Goodness-of-Fit Test: Comprehensive Guide

Master chi-square goodness-of-fit tests: testing if observed frequencies match expected distributions through these 5 detailed exercises.

Chi-Square Goodness-of-Fit Fundamentals
χ² = Σ[(Observed - Expected)²/Expected]
Chi-Square Formula
Key Definitions:

Observed Frequencies (O): Actual counts from the sample data

Expected Frequencies (E): Counts predicted by the null hypothesis

Degrees of Freedom: df = k - 1 (where k = number of categories)

Chi-Square Distribution: Right-skewed distribution used for categorical data tests

Goodness-of-Fit: Test of how well observed data fits expected distribution

5-Step Procedure:
  1. State hypotheses: H₀: Distribution matches expected, H₁: Distribution differs
  2. Check conditions: All expected frequencies ≥ 5
  3. Calculate test statistic: χ² = Σ[(O-E)²/E]
  4. Find p-value: Using chi-square distribution with df = k-1
  5. Make decision: Compare p-value to α
Tip 1: Always check that all expected frequencies ≥ 5
Tip 2: Chi-square values are always positive
Tip 3: Larger χ² values indicate greater disagreement between observed and expected
When to Use: Testing if sample distribution matches theoretical distribution
Assumptions: Random sample, independent observations, adequate expected frequencies
Solution: Exercises 1 to 3
1 Fair Die Test
Exercise 1
A die is rolled 60 times with the following results: 1(8), 2(12), 3(10), 4(11), 5(9), 6(10). Test if the die is fair at α = 0.05.
Problem Setup:

Categories: 6 faces of die

Total Rolls: n = 60

Observed: O₁=8, O₂=12, O₃=10, O₄=11, O₅=9, O₆=10

Test Procedure:

Testing if each face appears with equal probability (1/6)

Step 1: State hypotheses

H₀: Die is fair (p₁ = p₂ = p₃ = p₄ = p₅ = p₆ = 1/6)

H₁: Die is not fair (at least one pᵢ ≠ 1/6)

Step 2: Calculate expected frequencies

Under H₀, each face should appear 60 × (1/6) = 10 times

So E₁ = E₂ = E₃ = E₄ = E₅ = E₆ = 10

Step 3: Check conditions

All expected frequencies = 10 ≥ 5 ✓

Conditions are satisfied

Step 4: Calculate test statistic

χ² = Σ[(O-E)²/E]

χ² = [(8-10)²/10] + [(12-10)²/10] + [(10-10)²/10] + [(11-10)²/10] + [(9-10)²/10] + [(10-10)²/10]

χ² = [4/10] + [4/10] + [0/10] + [1/10] + [1/10] + [0/10]

χ² = 0.4 + 0.4 + 0 + 0.1 + 0.1 + 0 = 1.0

Step 5: Find degrees of freedom

df = k - 1 = 6 - 1 = 5

Step 6: Find p-value

For χ² = 1.0 and df = 5: p-value ≈ 0.960

Step 7: Make decision

Since p-value (0.960) > α (0.05), fail to reject H₀

Step 8: Conclusion

There is insufficient evidence to conclude that the die is unfair.

Final Answer:

χ² = 1.0, df = 5, p-value ≈ 0.960

Fail to reject H₀: Die appears to be fair

Applied Rules:

• Expected Calculation: E = n × p where p is the hypothesized probability

• Condition Check: All E ≥ 5 for chi-square validity

• Decision Rule: Reject H₀ if p-value ≤ α

2 Geographic Distribution
Exercise 2
A company claims their customers are distributed: 40% Northeast, 30% South, 20% West, 10% Midwest. A sample of 200 customers shows: 70 Northeast, 65 South, 45 West, 20 Midwest. Test at α = 0.05.
Problem Setup:

Categories: 4 geographic regions

Total Customers: n = 200

Claimed Proportions: p₁=0.40, p₂=0.30, p₃=0.20, p₄=0.10

Step 1: State hypotheses

H₀: Customer distribution matches claimed proportions

H₁: Customer distribution differs from claimed proportions

Step 2: Calculate expected frequencies

E₁ = 200 × 0.40 = 80 (Northeast)

E₂ = 200 × 0.30 = 60 (South)

E₃ = 200 × 0.20 = 40 (West)

E₄ = 200 × 0.10 = 20 (Midwest)

Step 3: Check conditions

All expected frequencies ≥ 5: 80, 60, 40, 20 ✓

Conditions satisfied

Step 4: Calculate test statistic

χ² = [(70-80)²/80] + [(65-60)²/60] + [(45-40)²/40] + [(20-20)²/20]

χ² = [100/80] + [25/60] + [25/40] + [0/20]

χ² = 1.25 + 0.417 + 0.625 + 0 = 2.292

Step 5: Find degrees of freedom

df = k - 1 = 4 - 1 = 3

Step 6: Find p-value

For χ² = 2.292 and df = 3: p-value ≈ 0.514

Step 7: Make decision

Since p-value (0.514) > α (0.05), fail to reject H₀

Step 8: Conclusion

There is insufficient evidence to conclude that customer distribution differs from claimed proportions.

Final Answer:

χ² = 2.292, df = 3, p-value ≈ 0.514

Fail to reject H₀: Customer distribution matches claimed proportions

Applied Rules:

• Proportional Expected: E = n × p for each category

• Degrees of Freedom: df = number of categories - 1

• Right-tailed Test: Chi-square tests are always right-tailed

3 Political Party Affiliation
Exercise 3
A political scientist claims voter party affiliation is: 45% Democrat, 40% Republican, 15% Independent. A survey of 400 voters found: 180 Democrats, 150 Republicans, 70 Independents. Test at α = 0.01.
Problem Setup:

Categories: 3 political parties

Total Voters: n = 400

Claimed Proportions: p₁=0.45, p₂=0.40, p₃=0.15

Step 1: State hypotheses

H₀: Voter distribution matches claimed proportions

H₁: Voter distribution differs from claimed proportions

Step 2: Calculate expected frequencies

E₁ = 400 × 0.45 = 180 (Democrat)

E₂ = 400 × 0.40 = 160 (Republican)

E₃ = 400 × 0.15 = 60 (Independent)

Step 3: Check conditions

All expected frequencies ≥ 5: 180, 160, 60 ✓

Conditions satisfied

Step 4: Calculate test statistic

χ² = [(180-180)²/180] + [(150-160)²/160] + [(70-60)²/60]

χ² = [0/180] + [100/160] + [100/60]

χ² = 0 + 0.625 + 1.667 = 2.292

Step 5: Find degrees of freedom

df = k - 1 = 3 - 1 = 2

Step 6: Find p-value

For χ² = 2.292 and df = 2: p-value ≈ 0.318

Step 7: Make decision

Since p-value (0.318) > α (0.01), fail to reject H₀

Step 8: Conclusion

At α = 0.01, there is insufficient evidence to conclude that voter distribution differs from claimed proportions.

Final Answer:

χ² = 2.292, df = 2, p-value ≈ 0.318

Fail to reject H₀: Voter distribution matches claimed proportions

Applied Rules:

• Conservative Alpha: α = 0.01 requires stronger evidence

• Large Sample: Adequate expected frequencies guaranteed

• Political Context: Important for polling and electoral analysis

Solution: Exercises 4 to 5
4 Product Sales Distribution
Exercise 4
A store manager claims product sales are distributed equally among 5 departments. A sample of 500 sales shows: 120, 85, 105, 95, 95. Test if the claim is valid at α = 0.05.
Problem Setup:

Categories: 5 departments

Total Sales: n = 500

Observed: O₁=120, O₂=85, O₃=105, O₄=95, O₅=95

Step 1: State hypotheses

H₀: Sales are equally distributed among departments

H₁: Sales are not equally distributed among departments

Step 2: Calculate expected frequencies

Under H₀: Each department should have 500/5 = 100 sales

E₁ = E₂ = E₃ = E₄ = E₅ = 100

Step 3: Check conditions

All expected frequencies = 100 ≥ 5 ✓

Conditions satisfied

Step 4: Calculate test statistic

χ² = [(120-100)²/100] + [(85-100)²/100] + [(105-100)²/100] + [(95-100)²/100] + [(95-100)²/100]

χ² = [400/100] + [225/100] + [25/100] + [25/100] + [25/100]

χ² = 4 + 2.25 + 0.25 + 0.25 + 0.25 = 7.0

Step 5: Find degrees of freedom

df = k - 1 = 5 - 1 = 4

Step 6: Find p-value

For χ² = 7.0 and df = 4: p-value ≈ 0.136

Step 7: Make decision

Since p-value (0.136) > α (0.05), fail to reject H₀

Step 8: Conclusion

There is insufficient evidence to conclude that sales are unequally distributed among departments.

Final Answer:

χ² = 7.0, df = 4, p-value ≈ 0.136

Fail to reject H₀: Sales appear equally distributed among departments

Applied Rules:

• Equal Distribution: Each category has expected frequency of n/k

• Departure Detection: Department 1 has highest sales, Department 2 lowest

• Business Application: Useful for inventory and staffing decisions

5 Grade Distribution
Exercise 5
A professor claims grades follow: 20% A, 30% B, 30% C, 15% D, 5% F. In a class of 200 students, the grades were: A(35), B(65), C(60), D(30), F(10). Test at α = 0.05.
Problem Setup:

Categories: 5 grade levels

Total Students: n = 200

Claimed Proportions: pA=0.20, pB=0.30, pC=0.30, pD=0.15, pF=0.05

Step 1: State hypotheses

H₀: Grade distribution matches claimed proportions

H₁: Grade distribution differs from claimed proportions

Step 2: Calculate expected frequencies

E_A = 200 × 0.20 = 40

E_B = 200 × 0.30 = 60

E_C = 200 × 0.30 = 60

E_D = 200 × 0.15 = 30

E_F = 200 × 0.05 = 10

Step 3: Check conditions

All expected frequencies ≥ 5: 40, 60, 60, 30, 10 ✓

Conditions satisfied

Step 4: Calculate test statistic

χ² = [(35-40)²/40] + [(65-60)²/60] + [(60-60)²/60] + [(30-30)²/30] + [(10-10)²/10]

χ² = [25/40] + [25/60] + [0/60] + [0/30] + [0/10]

χ² = 0.625 + 0.417 + 0 + 0 + 0 = 1.042

Step 5: Find degrees of freedom

df = k - 1 = 5 - 1 = 4

Step 6: Find p-value

For χ² = 1.042 and df = 4: p-value ≈ 0.905

Step 7: Make decision

Since p-value (0.905) > α (0.05), fail to reject H₀

Step 8: Conclusion

There is insufficient evidence to conclude that the grade distribution differs from the claimed proportions.

Final Answer:

χ² = 1.042, df = 4, p-value ≈ 0.905

Fail to reject H₀: Grade distribution matches claimed proportions

Applied Rules:

• Grade Curve: Common in academic settings

• Close Match: Observed values very close to expected

• High P-value: Strong evidence supporting the null hypothesis

Comprehensive Chi-Square Goodness-of-Fit Guide
χ² = Σ[(O-E)²/E], df = k-1
Core Formula
Test Statistic
χ² = Σ[(O-E)²/E]
Measures deviation from expected
Degrees of Freedom
df = k - 1
Number of independent comparisons
Expected Frequency
E = n × p
Under null hypothesis
Key Chi-Square Concepts:

Null Hypothesis (H₀): Observed distribution matches the expected distribution

Alternative Hypothesis (H₁): Observed distribution differs from expected

Chi-Square Distribution: Family of distributions indexed by degrees of freedom

Right-Tailed Test: Only large χ² values provide evidence against H₀

Independence: Observations must be independent of each other

Conditions and Assumptions:

Random Sampling: Data must come from a random sample

Independence: Observations must be independent

Expected Frequency Rule: All E ≥ 5 (some allow 1/5 of categories to have E < 5)

Categorical Data: Variables must be categorical (nominal or ordinal)

Fixed Categories: Number and definition of categories must be fixed in advance

Memory Tip: "Chi-square is always positive and right-tailed"
Memory Tip: "Larger chi-square = greater disagreement between observed and expected"
Memory Tip: "Degrees of freedom = number of categories - 1"
Common Mistakes: Forgetting to check expected frequency conditions, miscalculating expected frequencies, misinterpreting p-values
Applications: Genetics, quality control, market research, survey validation, goodness of fit testing

Questions & Answers

Question: Why do we require all expected frequencies to be at least 5? What happens if this condition isn't met?

Answer: The expected frequency condition (E ≥ 5) is crucial for the validity of the chi-square test:

Reason for the Condition:

  • The chi-square test relies on the normal approximation to the multinomial distribution
  • When expected frequencies are small, the normal approximation becomes poor
  • The chi-square distribution may not accurately model the test statistic's behavior

What Happens When Condition Isn't Met:

  • The p-value may be inaccurate
  • Test may have inflated Type I error rate (too likely to reject H₀)
  • Power of the test may be affected

Solutions When Condition Isn't Met:

  • Combine categories: Merge adjacent categories with low expected frequencies
  • Use exact test: Binomial test for 2 categories, exact multinomial test for multiple categories
  • Collect more data: Increase sample size to boost expected frequencies

The condition ensures the chi-square approximation is reliable and the test maintains its intended properties.

Question: How do I interpret a chi-square test result? What does it tell me about the relationship between observed and expected values?

Answer: Interpreting chi-square results involves several key components:

Test Statistic (χ²):

  • Measures the total discrepancy between observed and expected frequencies
  • Larger values indicate greater disagreement between observed and expected
  • Always non-negative (≥ 0)

P-value Interpretation:

  • P-value = P(obtaining a χ² value at least as extreme as observed | H₀ is true)
  • Small p-value (≤ α): Evidence that observed distribution differs from expected
  • Large p-value (> α): Insufficient evidence to conclude difference exists

Decision Making:

  • If p-value ≤ α: Reject H₀ → Distribution differs from expected
  • If p-value > α: Fail to reject H₀ → Distribution appears to match expected

Important Note: The test only tells you if there's a significant difference—it doesn't tell you which specific categories differ. For that, examine the individual (O-E)²/E contributions.

Effect Size: Consider the practical significance of differences, not just statistical significance.

Question: Why is the chi-square goodness-of-fit test always right-tailed? Why don't we have left-tailed or two-tailed versions?

Answer: This is a fundamental characteristic of the chi-square test that stems from its construction:

Reason for Right-Tailed Nature:

  • Formula Structure: χ² = Σ[(O-E)²/E]
  • Squared Terms: (O-E)² is always non-negative
  • Positive Contributions: Each category contributes a non-negative value to the total
  • Minimum Value: χ² = 0 occurs only when O = E for all categories

Interpretation:

  • χ² = 0: Perfect agreement between observed and expected
  • χ² > 0: Some disagreement exists (larger values = more disagreement)
  • Large χ² values: Strong evidence against H₀ (distribution differs)

Why No Left Tail:

There's no concept of "negative disagreement"—we can't have observed frequencies that are "too close" to expected in a meaningful way that would create negative test statistics.

Alternative Approach:

Instead of two-tailed tests, we might examine which specific categories contribute most to the overall chi-square value to understand the nature of any differences.

The right-tailed nature makes the test naturally suited for detecting departures from the expected distribution in any direction.