Study Guide

Chi-squared tests

Further MathematicsΒ· 9231 Unit 4: Further Probability & Statistics, Section 6Β· 25 min read

1. Chi-squared Goodness of Fit Test Basicsβ˜…β˜…β˜†β˜†β˜†β± 6 min

πŸ“˜ Definition

Chi-squared test statistic

Ο‡2=βˆ‘(Oiβˆ’Ei)2Ei\chi^2 = \sum \frac{(O_i - E_i)^2}{E_i}

Sum of squared differences between observed and expected frequencies, normalised by the expected frequency for each category.

For a goodness of fit test, the null hypothesis states that the sample data follows a specified theoretical distribution. The alternative hypothesis states the data does not follow that distribution. Expected frequencies are calculated directly from the theoretical distribution, scaled to the total sample size.

πŸ“ Worked Example

A fair 6-sided die is rolled 120 times, with observed scores: 25, 18, 22, 17, 21, 17. Calculate the chi-squared test statistic to test if the die is fair.

  1. 1

    Total sample size = 120. For a fair die, expected frequency for each of 6 outcomes = 120 / 6 = 20.

  2. 2

    Compute each (O_i - E_i)^2 / E_i term:

  3. 3
    (25βˆ’20)220+(18βˆ’20)220+(22βˆ’20)220+(17βˆ’20)220+(21βˆ’20)220+(17βˆ’20)220\frac{(25-20)^2}{20} + \frac{(18-20)^2}{20} + \frac{(22-20)^2}{20} + \frac{(17-20)^2}{20} + \frac{(21-20)^2}{20} + \frac{(17-20)^2}{20}
  4. 4

    Sum the terms: 1.25 + 0.2 + 0.2 + 0.45 + 0.05 + 0.45 = 2.6

βœ“ Quick check
  1. What is the expected frequency for a category if total sample size is 200 and theoretical probability of the category is 0.15?

    Reveal answer
    30 β€”

    E_i = n * p_i = 200 * 0.15 = 30

Exam tip:

CIE examiners will deduct marks if you do not explicitly state that all expected frequencies are >=5 before proceeding with the test.

2. Degrees of Freedom Calculationβ˜…β˜…β˜…β˜†β˜†β± 6 min

Degrees of freedom for a chi-squared test are calculated as the number of independent pieces of information used to compute the test statistic. For goodness of fit tests, you subtract 1 for the total sample size constraint, plus 1 for every population parameter estimated from the sample data.

Ξ½=kβˆ’mβˆ’1\nu = k - m - 1
  • k = number of categories after merging any groups with E_i < 5

  • m = number of parameters estimated from sample data to define the theoretical distribution

πŸ“ Worked Example

You fit a normal distribution to 8 categories of grouped data, estimating mean and variance from the sample. All expected frequencies are >=5. Find the degrees of freedom.

  1. 1

    Number of categories k = 8

  2. 2

    Number of estimated parameters m = 2 (mean and variance)

  3. 3
    Ξ½=8βˆ’2βˆ’1=5\nu = 8 - 2 - 1 = 5
βœ“ Quick check
  1. You test if data follows a Poisson distribution, estimating lambda from the sample, with 4 categories. What is the df?

    Reveal answer
    2 β€”

    4 - 1 -1 = 2

Exam tip:

Never subtract extra degrees of freedom for parameters that are given in the question, only for values you calculate from the sample.

3. Chi-squared Test for Independenceβ˜…β˜…β˜…β˜†β˜†β± 7 min

This test assesses if two categorical variables are independent of each other, using a contingency table. The null hypothesis states the two variables are independent, the alternative states they are associated. Expected frequency for each cell is calculated as (row total * column total) / grand total.

Eij=RiΓ—CjNE_{ij} = \frac{R_i \times C_j}{N}
πŸ“ Worked Example

A 3x2 contingency table has row totals 40, 60, 50, column totals 70, 80, grand total 150. Calculate the expected frequency for the cell in row 2, column 1.

  1. 1

    Row 2 total R_2 = 60, Column 1 total C_1 =70

  2. 2
    E21=60Γ—70150=28E_{21} = \frac{60 \times 70}{150} = 28

Degrees of freedom for an r x c contingency table is (r-1)(c-1), where r is number of rows and c number of columns, no extra subtractions required.

Exam tip:

You can verify your expected frequencies are correct by checking that all row and column totals match the observed contingency table totals.

4. Yates' Continuity Correctionβ˜…β˜…β˜…β˜†β˜†β± 6 min

The chi-squared distribution is continuous, but the test statistic calculated from 2x2 contingency tables is discrete. Yates' correction adjusts the test statistic to reduce this approximation error, and is mandatory for all 2x2 tables in the CIE 9231 syllabus.

Ο‡Yates2=βˆ‘(∣Oiβˆ’Eiβˆ£βˆ’0.5)2Ei\chi^2_{\text{Yates}} = \sum \frac{(|O_i - E_i| - 0.5)^2}{E_i}
πŸ“ Worked Example

For a 2x2 table, the difference between observed and expected for each cell is 1.2. Calculate the Yates corrected test statistic.

  1. 1

    Subtract 0.5 from absolute difference: |1.2| - 0.5 = 0.7

  2. 2

    Square the value: 0.7^2 = 0.49

  3. 3

    Sum over 4 cells, each with E_i = 25: 4 * (0.49 / 25) = 0.0784

5. Common Pitfalls

Wrong move:

Failing to combine expected frequencies less than 5

Why:

Breaks the chi-squared distribution approximation assumption, leading to inflated test statistics and incorrect conclusions

Correct move:

Merge adjacent categories until all E_i >=5, then reduce degrees of freedom by the number of merged groups minus 1

Wrong move:

Applying Yates' correction to 3x2 or larger contingency tables

Why:

Yates' correction is only designed for 2x2 tables, and produces overly conservative test results for larger tables

Correct move:

Only use Yates' correction explicitly when the contingency table is 2 rows by 2 columns

Wrong move:

Forgetting to subtract degrees of freedom for parameters estimated from sample data

Why:

Overestimates degrees of freedom, leading you to pick an overly lenient critical value and incorrectly reject the null hypothesis

Correct move:

Explicitly count all parameters you calculated from the observed data to define the theoretical distribution, subtract 1 per parameter from df

Wrong move:

Using observed totals instead of (row total * column total)/grand total to calculate contingency table expected frequencies

Why:

Produces invalid expected values that do not reflect the independence assumption

Correct move:

Verify all expected row and column totals exactly match the observed table totals before calculating the test statistic

Wrong move:

Stating the null hypothesis as 'the two variables are correlated'

Why:

Chi-squared tests for independence do not measure linear correlation, they test for any association between categorical variables

Correct move:

Explicitly write H0 as 'the two variables are independent' and H1 as 'the two variables are not independent'

6. Quick Reference Cheatsheet

Test Type

Degrees of Freedom Formula

Required Adjustments

Goodness of fit, no parameters estimated

k - 1

Merge categories if E_i < 5

Goodness of fit, m parameters estimated

k - m - 1

Merge categories if E_i < 5

r x c Contingency table (r>2 or c>2)

(r-1)(c-1)

Merge rows/columns if E_i <5

2 x 2 Contingency table

1

Apply Yates' continuity correction

7. Frequently Asked

When do I need to combine expected frequencies?

CIE requires you to combine adjacent categories if any expected frequency is less than 5. You must reduce the degrees of freedom by the number of categories you merged.

Can a chi-squared test be one-tailed or two-tailed?

All standard chi-squared tests in the 9231 syllabus are right-tailed, as large deviations from expected values only occur in the upper tail of the distribution.

When this came up on past exams

AI-estimated based on syllabus patterns β€” cross-check with official past papers for accuracy. Use only as revision-focus signals.

  • 2024 Β· 4

    Goodness of fit test for Poisson distribution

  • 2023 Β· 3

    Test for independence 3x2 contingency table

  • 2022 Β· 4

    Yates' correction for 2x2 table

What's Next

Mastering chi-squared tests gives you a core tool for analysing categorical data that appears in almost every CIE 9231 exam paper. Next, you will build on this hypothesis testing foundation to learn non-parametric tests that can be used when your data does not meet the assumptions of standard parametric tests like t-tests. You will also explore hypothesis testing for correlation coefficients, which lets you assess the statistical significance of linear relationships between continuous variables. These topics are frequently paired with chi-squared questions in extended problem sets, so solidifying your understanding now will boost your performance in the final exam.