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
Chi-squared test statistic
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.
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
Total sample size = 120. For a fair die, expected frequency for each of 6 outcomes = 120 / 6 = 20.
- 2
Compute each (O_i - E_i)^2 / E_i term:
- 3
- 4
Sum the terms: 1.25 + 0.2 + 0.2 + 0.45 + 0.05 + 0.45 = 2.6
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 = number of categories after merging any groups with E_i < 5
m = number of parameters estimated from sample data to define the theoretical distribution
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
Number of categories k = 8
- 2
Number of estimated parameters m = 2 (mean and variance)
- 3
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.
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
Row 2 total R_2 = 60, Column 1 total C_1 =70
- 2
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' Correction Is Not Required (9231)★★★☆☆⏱ 6 min
In Cambridge 9231, the test for independence in a contingency table does not require Yates' continuity correction — this includes 2×2 tables. Use the standard statistic for every table, combining rows or columns where necessary so that each expected frequency is at least 5. (Many external textbooks and software such as SPSS apply Yates by default, but 9231 does not.)
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' continuity correction to a 2×2 (or any) contingency table
Why:
CIE 9231 does not require Yates' correction; the standard is used for every table, and applying the correction can lose marks
Correct move:
Use the standard for all contingency tables, including 2×2
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 | Standard (no Yates) |
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.
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.
