Kramizo
Log inSign up free
HomeAP StatisticsInference for Categorical Data: Chi-Square
AP · · Statistics · Revision Notes

Inference for Categorical Data: Chi-Square

2,183 words · Last updated July 2026

Ready to practise? Test yourself on Inference for Categorical Data: Chi-Square with instantly-marked questions.
Practice now →
Quick answer

Chi-square tests analyze categorical data using three forms: goodness-of-fit (one variable vs. hypothesized distribution), homogeneity (same variable across populations), and independence (two variables, one sample). All require random sampling, independence (n < 10% population), and expected counts ≥ 5. Calculate χ² = Σ(O-E)²/E with appropriate df. Use upper-tail p-values from chi-square distribution. Always state conclusions in context and distinguish association from causation.

What you'll learn

This guide covers all aspects of chi-square inference required for AP Statistics examinations. You will learn how to conduct and interpret chi-square goodness-of-fit tests, chi-square tests for homogeneity, and chi-square tests for independence. The content focuses on understanding when to use each test, calculating test statistics, determining degrees of freedom, and making appropriate conclusions in context.

Key terms and definitions

Chi-square statistic (χ²) — A test statistic calculated as the sum of (observed - expected)²/expected across all categories, used to measure the discrepancy between observed and expected frequencies in categorical data.

Expected count — The frequency predicted for a category under the null hypothesis, calculated differently depending on the type of chi-square test being performed.

Degrees of freedom (df) — The number of categories that are free to vary when calculating chi-square statistics; determines which chi-square distribution to use for finding p-values.

Goodness-of-fit test — A chi-square test comparing observed frequencies in a single categorical variable to expected frequencies based on a hypothesized distribution.

Test for independence — A chi-square test examining whether two categorical variables measured on the same individuals are associated or independent.

Test for homogeneity — A chi-square test comparing the distribution of a single categorical variable across two or more independent populations or groups.

Conditions for chi-square inference — Requirements that must be checked before conducting a chi-square test: random sampling, independence (sample size < 10% of population), and all expected counts ≥ 5.

Two-way table — A contingency table displaying frequencies for two categorical variables, with rows representing one variable and columns representing another.

Core concepts

When to use each chi-square test

The three chi-square tests differ in their purpose and data structure:

Chi-square goodness-of-fit test:

  • One categorical variable from a single sample
  • Compare observed distribution to a hypothesized distribution
  • Example: Testing whether dice rolls follow a uniform distribution
  • Null hypothesis specifies exact probabilities for each category

Chi-square test for homogeneity:

  • One categorical variable measured across multiple independent groups
  • Compare distributions across different populations
  • Example: Comparing political party preference across three Caribbean islands
  • Data collection: separate random samples from each population

Chi-square test for independence:

  • Two categorical variables measured on same individuals
  • Determine if variables are associated or independent
  • Example: Examining relationship between gender and mobile phone preference
  • Data collection: single random sample with two variables recorded per individual

The distinction between homogeneity and independence tests lies in data collection method, though the calculation procedure is identical.

Conditions for chi-square tests

Before conducting any chi-square test, verify three essential conditions:

Random condition:

  • Data must come from a random sample or randomized experiment
  • State explicitly: "The data come from a random sample of..."
  • If condition fails, inference is not valid

Independence condition (10% condition):

  • When sampling without replacement, sample size must be less than 10% of population
  • State: "The sample size of n is less than 10% of all..."
  • For multiple samples (homogeneity), check for each group separately
  • Ensures individual observations are independent

Large counts condition:

  • All expected counts must be at least 5
  • Check expected counts, not observed counts
  • State: "All expected counts are at least 5"
  • If violated, chi-square distribution is not appropriate approximation

Calculating the chi-square statistic

The chi-square test statistic follows the same formula for all three tests:

χ² = Σ [(observed - expected)²/expected]

For goodness-of-fit tests:

  • Expected count for each category = n × hypothesized proportion
  • Where n is the total sample size
  • Sum across all categories in the single variable

For homogeneity and independence tests:

  • Expected count for each cell = (row total × column total)/grand total
  • Calculate separately for each cell in the two-way table
  • Sum across all cells

The test statistic measures total deviation from what we'd expect under H₀. Larger χ² values indicate greater discrepancy between observed and expected counts, providing stronger evidence against the null hypothesis.

Degrees of freedom

Degrees of freedom determine which chi-square distribution to use:

Goodness-of-fit test:

  • df = number of categories - 1
  • Example: Testing a die (6 outcomes) gives df = 5

Homogeneity and independence tests:

  • df = (number of rows - 1) × (number of columns - 1)
  • Example: 3×4 table gives df = (3-1)(4-1) = 6
  • Ignore row and column totals when counting

Degrees of freedom account for constraints imposed by knowing marginal totals. Once df cells are filled, the remaining cells are determined by the totals.

Hypothesis testing framework

Goodness-of-fit hypotheses:

  • H₀: The true distribution matches the hypothesized distribution (specify exact proportions)
  • Hₐ: The true distribution differs from the hypothesized distribution
  • State in context with actual proportions

Homogeneity hypotheses:

  • H₀: The distribution of [variable] is the same for all [populations]
  • Hₐ: The distribution of [variable] differs among [populations]
  • Alternative is always two-sided

Independence hypotheses:

  • H₀: There is no association between [variable 1] and [variable 2]
  • Hₐ: There is an association between [variable 1] and [variable 2]
  • Equivalent: variables are independent vs. dependent

P-value interpretation:

  • All chi-square tests are upper-tail tests (only right tail)
  • P-value = P(χ² ≥ observed test statistic)
  • Use chi-square distribution with appropriate df
  • Smaller p-values provide stronger evidence against H₀

Conclusion:

  • If p-value < α: Reject H₀, we have convincing evidence for Hₐ
  • If p-value ≥ α: Fail to reject H₀, we do not have convincing evidence for Hₐ
  • Always state conclusion in context of the problem
  • Never "accept" H₀ or "prove" anything

Reading computer output and using tables

Calculator/software output typically shows:

  • χ² test statistic value
  • P-value
  • Degrees of freedom
  • Sometimes expected counts and contributions to χ²

Using chi-square tables:

  • Locate correct df row
  • Find where test statistic falls among critical values
  • Determine p-value range
  • Example: χ² = 8.42 with df = 3 falls between 0.025 and 0.05

Identifying unusual cells:

  • Calculate contribution for each cell: (O - E)²/E
  • Cells with largest contributions drive significant results
  • Compare observed to expected: which cells differ most?

Worked examples

Example 1: Chi-square goodness-of-fit test

Question: A Caribbean telecommunications company claims that customer complaints are distributed evenly across the week. A random sample of 210 complaints shows: Monday (38), Tuesday (35), Wednesday (28), Thursday (32), Friday (42), Saturday (20), Sunday (15). Test at α = 0.05 whether complaints are uniformly distributed.

Solution:

State hypotheses:

  • H₀: Complaints are uniformly distributed across all seven days (p₁ = p₂ = ... = p₇ = 1/7)
  • Hₐ: Complaints are not uniformly distributed across the seven days

Check conditions:

  • Random: Stated as random sample ✓
  • 10%: 210 < 10% of all complaints received ✓
  • Large counts: Expected count for each day = 210/7 = 30 ≥ 5 ✓

Calculate test statistic: Expected count for each day = 210 × (1/7) = 30

Day Observed Expected (O-E)²/E
Mon 38 30 2.133
Tue 35 30 0.833
Wed 28 30 0.133
Thu 32 30 0.133
Fri 42 30 4.800
Sat 20 30 3.333
Sun 15 30 7.500

χ² = 2.133 + 0.833 + 0.133 + 0.133 + 4.800 + 3.333 + 7.500 = 18.865

Find p-value:

  • df = 7 - 1 = 6
  • P-value = P(χ² ≥ 18.865) = 0.0044

Conclusion: Since p-value (0.0044) < α (0.05), we reject H₀. We have convincing evidence that customer complaints are not uniformly distributed across the days of the week. The data suggest fewer complaints on weekends, particularly Sunday.

Example 2: Chi-square test for independence

Question: A study examines whether there is an association between education level and support for a new environmental policy among 400 randomly selected UK residents. Results:

Support Oppose No opinion
Secondary 45 65 30
University 85 55 25
Postgraduate 60 25 10

Test at α = 0.01 whether education level and policy support are independent.

Solution:

State hypotheses:

  • H₀: There is no association between education level and environmental policy support
  • Hₐ: There is an association between education level and environmental policy support

Check conditions:

  • Random: Random sample of 400 UK residents ✓
  • 10%: 400 < 10% of all UK residents ✓
  • Large counts: Calculate expected counts using (row total × column total)/grand total

Expected counts:

  • Secondary/Support: (140 × 190)/400 = 66.5
  • Secondary/Oppose: (140 × 145)/400 = 50.75
  • Secondary/No opinion: (140 × 65)/400 = 22.75

All expected counts ≥ 5 ✓

Calculate test statistic:

χ² = (45-66.5)²/66.5 + (65-50.75)²/50.75 + (30-22.75)²/22.75 + (85-71.25)²/71.25 + (55-54.69)²/54.69 + (25-23.06)²/23.06 + (60-52.25)²/52.25 + (25-39.56)²/39.56 + (10-19.19)²/19.19

χ² = 6.964 + 4.011 + 2.314 + 2.651 + 0.002 + 0.163 + 1.150 + 5.357 + 4.401 = 27.013

Find p-value:

  • df = (3-1)(3-1) = 4
  • P-value = P(χ² ≥ 27.013) < 0.0001

Conclusion: Since p-value < α (0.01), we reject H₀. We have convincing evidence of an association between education level and environmental policy support. Postgraduates show stronger support and less opposition than expected.

Example 3: Chi-square test for homogeneity

Question: Researchers compare smartphone brand preference across three Caribbean islands. Random samples: Jamaica (n=150), Trinidad (n=120), Barbados (n=130). Is brand preference homogeneous across islands? Use α = 0.05.

Island Brand A Brand B Brand C Other
Jamaica 55 42 38 15
Trinidad 38 35 30 17
Barbados 50 36 28 16

Solution:

State hypotheses:

  • H₀: The distribution of smartphone brand preference is the same across all three islands
  • Hₐ: The distribution of smartphone brand preference differs among the three islands

Check conditions:

  • Random: Random samples from each island ✓
  • 10%: Each sample < 10% of island population ✓
  • Large counts: All expected counts ≥ 5 (smallest: 48×130/400 = 15.6) ✓

Calculate test statistic: Using expected = (row total × column total)/400

χ² = 1.923 + 0.343 + 0.952 + 0.021 + 0.679 + 0.042 + 0.068 + 0.167 + 0.286 + 2.231 + 0.095 + 0.094 = 6.901

Find p-value:

  • df = (3-1)(4-1) = 6
  • P-value = P(χ² ≥ 6.901) = 0.331

Conclusion: Since p-value (0.331) > α (0.05), we fail to reject H₀. We do not have convincing evidence that smartphone brand preference differs among Jamaica, Trinidad, and Barbados.

Common mistakes and how to avoid them

  • Confusing observed and expected counts when checking conditions. Always verify that expected counts (not observed) are all ≥ 5. Calculate expected counts using the appropriate formula before checking this condition.

  • Incorrect degrees of freedom calculation. For two-way tables, use (rows - 1) × (columns - 1), not total cells minus 1. For goodness-of-fit, use categories - 1. Double-check your df calculation.

  • Using two-tailed p-values. Chi-square tests are always one-tailed (upper tail only) because χ² values are never negative. The p-value is always P(χ² ≥ test statistic).

  • Failing to state conclusions in context. Never write "reject H₀" alone. Always relate your conclusion to the specific variables and scenario: "We have convincing evidence that [specific context]."

  • Confusing independence and homogeneity tests. Both use identical calculations but differ in data collection. Independence: one sample, two variables measured. Homogeneity: multiple samples, one variable measured.

  • Forgetting to verify all three conditions. Random sampling, independence (10% condition), and large counts must all be checked and stated explicitly. Examiners award marks for proper condition verification.

Exam technique for "Inference for Categorical Data: Chi-Square"

  • Follow the four-step inference procedure consistently: State (hypotheses), Plan (conditions and test name), Do (calculations and p-value), Conclude (in context). AP exam rubrics award marks for each component.

  • Show calculation structure clearly. Even when using a calculator, demonstrate the formula structure for at least one cell: (observed - expected)²/expected. This earns partial credit if final answers contain errors.

  • Distinguish between "association" and "causation." Chi-square tests detect association only. Even with significant results, state "association" not "causes" unless the study design was a randomized experiment.

  • Compare observed to expected when interpreting results. After rejecting H₀, identify which categories or cells contributed most to the significant result by comparing their observed and expected values.

Quick revision summary

Chi-square tests analyze categorical data using three forms: goodness-of-fit (one variable vs. hypothesized distribution), homogeneity (same variable across populations), and independence (two variables, one sample). All require random sampling, independence (n < 10% population), and expected counts ≥ 5. Calculate χ² = Σ(O-E)²/E with appropriate df. Use upper-tail p-values from chi-square distribution. Always state conclusions in context and distinguish association from causation.

Inference for Categorical Data: Chi-Square: common questions

What do you need to know about Inference for Categorical Data: Chi-Square for AP Statistics?

Chi-square tests analyze categorical data using three forms: goodness-of-fit (one variable vs. hypothesized distribution), homogeneity (same variable across populations), and independence (two variables, one sample). All require random sampling, independence (n < 10% population), and expected counts ≥ 5. Calculate χ² = Σ(O-E)²/E with appropriate df. Use upper-tail p-values from chi-square distribution. Always state conclusions in context and distinguish association from causation.

What are the most common mistakes in Inference for Categorical Data: Chi-Square?

Confusing observed and expected counts when checking conditions: Always verify that expected counts (not observed) are all ≥ 5. Calculate expected counts using the appropriate formula before checking this condition. Incorrect degrees of freedom calculation: For two-way tables, use (rows - 1) × (columns - 1), not total cells minus 1. For goodness-of-fit, use categories - 1. Double-check your df calculation. Using two-tailed p-values: Chi-square tests are always one-tailed (upper tail only) because χ² values are never negative. The p-value is always P(χ² ≥ test statistic).

Where can I practise Inference for Categorical Data: Chi-Square questions for free?

Kramizo has free AP Statistics practice questions on Inference for Categorical Data: Chi-Square, each marked instantly with a full explanation. No card is required.

Free for students

Lock in Inference for Categorical Data: Chi-Square with real exam questions.

Free instantly-marked AP Statistics practice — 45 questions a day, no card required.

Try a question →See practice bank