A Level Further Mathematics · Chapter 43 · Further Statistics · Further Statistics 1
A chi-squared test measures how far observed frequencies stray from the frequencies a model predicts, and asks whether that gap is too big to be chance.
Is a die fair, do goals in football follow a Poisson model, and is a student's choice of subject linked to their year group? This chapter develops the chi-squared test, which answers each question by comparing counted data with what a model predicts.
In this chapter · jump to a section
Start here
Your route through this chapter
By the end of this chapter you will be able to:
- calculate the statistic from observed and expected frequencies
- find the degrees of freedom and the critical value for a test
- pool classes so that every expected frequency is at least 5
- test the fit of uniform, binomial, Poisson and geometric models, with or without estimated parameters
- test for independence in a contingency table
- interpret the size and direction of the contributions, and state conclusions in context
Time: three sessions, about 4½ hours, plus the practice ladder and the exam workshop.
You need first: hypothesis testing, and the binomial, Poisson and geometric distributions.
The big idea
The big idea
Count how many observations fall into each class. These are the observed frequencies . A model gives the frequencies we would expect. The test statistic adds up the squared gaps, each scaled by its expected frequency:
If the model is right, approximately follows a chi-squared distribution. A large value means the data fit the model badly.
The diagram shows 120 rolls of a die. No die gives exactly 20 of each score, so some gap is expected. The chi-squared test decides whether the gaps here are larger than chance alone would usually produce.
Why square and divide?
Squaring makes every gap positive, so gaps above and below the expected value cannot cancel. Dividing by the expected frequency puts each gap on a fair scale. A gap of 6 matters a lot when 10 were expected, but very little when 1000 were. The resulting statistic behaves in a predictable way, which is what makes the test possible.
Who developed the test
The chi-squared test was introduced in 1900, and it is one of the oldest tests still in everyday use. Ronald Fisher later corrected the rule for degrees of freedom when parameters are estimated. The test is used throughout science, from genetics, where it checked Mendel's ratios, to market research and medicine.
Goodness of fit and independence
The chapter covers two uses of the same statistic. A goodness-of-fit test compares one set of counts with a proposed distribution. A test of independence compares a two-way table of counts with what we would expect if two factors were unrelated. Both use the same formula and the same distribution, but they differ in how the expected frequencies and degrees of freedom are found.
A statistic built from counts
Everything in this chapter starts from counting. Each observation is placed in exactly one class, and the number in each class is recorded. The test never looks at the individual values again. This makes it very flexible, because almost any data can be sorted into classes. It also means that the choice of classes matters, and different choices can lead to slightly different results.
What the test can and cannot say
A chi-squared test can show that a model fits badly. It cannot prove that a model is right. A non-significant result means only that the data are consistent with the model, and other models might fit just as well. This is the same logic as every hypothesis test: we look for evidence against the null hypothesis, and absence of evidence is not proof.
Section 1
The goodness-of-fit statistic
Setting up the test
State the hypotheses in words. The null hypothesis is that the proposed model fits the data, such as the die is fair. The alternative is that it does not. Then find the expected frequency in each class by multiplying the total number of observations by the probability the model gives that class.
Common mistake: dividing by the observed frequency instead of the expected frequency. Each contribution is , scaled by what the model predicts. Dividing by gives a different statistic that does not follow the chi-squared distribution, so its critical values are meaningless.
Observed against expected frequencies
- Contributions (O − E)²/E
- 1.25, 0.2, 0.2, 1.8, 0.45, 0.2
- Statistic Σ(O − E)²/E
- 4.1
- Critical value, ν = 5, 5%
- 11.07
- Decision
- do not reject H₀
Figure 43.1 shows observed and expected frequencies side by side, with each class's contribution to the statistic. The wrong model's division by gives a different total.
Contributions
Each class contributes to the statistic. Listing the contributions shows which classes cause the most disagreement. A single large contribution can drive the whole result. Looking at the contributions, not just the total, is an important part of interpreting a test.
Expected frequencies need not be whole numbers
Observed frequencies are always whole numbers, but expected frequencies need not be. If a model predicts 20.48 observations in a class, use 20.48, not 20. Rounding the expected frequencies introduces errors into the statistic. Keep at least two decimal places in the working.
Checking the totals
The expected frequencies must add up to the same total as the observed frequencies. This is a quick and valuable check. If they do not match, a probability has been missed or a class has been left out. The final class often needs to cover all remaining values, such as four or more, to make the totals agree.
Choosing the classes
Sometimes the classes are natural, such as the six faces of a die. Sometimes they must be chosen, such as grouping waiting times into intervals. Use classes that every observation falls into, with no overlaps and no gaps. A sensible number of classes keeps each one reasonably full while still showing the shape of the data. Too few classes hide the shape, and too many make each class too small.
Writing hypotheses in words
The null hypothesis should name the model clearly, such as the die is fair or the scores are equally likely. The alternative is simply that the model does not fit. Avoid writing hypotheses about a single parameter, because the test checks the whole distribution at once. A clear statement in words earns the first mark and makes the conclusion easy to write.
A table keeps the working tidy
Set the working out as a table with columns for the class, the observed frequency, the expected frequency and the contribution. Then add the contribution column to get the statistic. This layout makes errors easy to spot and lets the examiner follow each step. It also leaves the contributions ready for interpreting the result at the end.
Worked example 1: a die
A die is rolled 120 times, giving the scores 1 to 6 with frequencies 15, 22, 18, 26, 17 and 22. Find the statistic for testing whether the die is fair.
| Working | Reason |
|---|---|
| Expected frequency for each score | A fair die makes each score equally likely |
| Add the squared gaps, each divided by twenty | |
| Evaluate the total to get the statistic |
Large samples sharpen the test
The same proportions give a bigger statistic in a bigger sample. If every count doubles, every squared gap is multiplied by four, while every expected frequency only doubles. So each contribution doubles. This is why large samples can detect small departures from a model that a small sample would miss entirely.
Worked example 2: three coins
Three fair coins are tossed 80 times, and the numbers of heads 0, 1, 2 and 3 occur 6, 34, 28 and 12 times. Find the statistic for testing the model .
| Working | Reason |
|---|---|
| Expected frequencies | Multiply the binomial probabilities by eighty |
| Divide each squared gap by its expected frequency | |
| Add the four contributions |
Check yourself. Two classes have observed frequencies 30 and 10 and expected frequencies 20 and 20. Find the statistic.
Show the answer
Each class has a gap of 10, so each contributes . The statistic is , a large value for so few classes.
Section 2
Degrees of freedom and critical values
Counting degrees of freedom
The number of degrees of freedom is
The 1 is subtracted because the expected frequencies are forced to have the same total as the observed ones. Each parameter estimated from the data uses up one more degree of freedom.
Common mistake: forgetting to subtract a degree of freedom for each estimated parameter. If the Poisson rate or the binomial probability is estimated from the data, the expected frequencies are pulled towards the observed ones. The statistic is then smaller than it would otherwise be, so fewer degrees of freedom must be used to compensate.
Degrees of freedom and the critical value
- Degrees of freedom ν = k − 1 − m
- 4
- Critical value at 5%
- 9.488
Figure 43.2 shows the chi-squared distribution for the correct degrees of freedom and its critical value. The wrong model's critical value, with too many degrees of freedom, is too large.
The chi-squared distribution
The chi-squared distribution with degrees of freedom is skewed to the right, starting at zero. Its mean is . As increases, it moves to the right and becomes more symmetric. Critical values come from tables or a calculator, which give the value with a stated probability in the upper tail.
The test is one-tailed
The chi-squared test uses only the upper tail. A large statistic means a bad fit. A very small statistic would mean the data fit suspiciously well, which is not usually what a test is looking for. So compare the statistic with the upper critical value at the chosen significance level, and reject the null hypothesis if it is larger.
Reading the tables
Chi-squared tables list critical values by degrees of freedom and significance level. Find the row for and the column for the significance level. For example, with 5 degrees of freedom at the 5% level, the critical value is 11.070. Write the value down with the degrees of freedom and level, so that the examiner can see where it came from.
Why the fixed total costs a freedom
Once all but one of the observed frequencies are known, the total fixes the last one. So the classes are not all free to vary. The same is true of the gaps between observed and expected frequencies, which always add up to zero. That single constraint is the reason one degree of freedom is lost in every chi-squared test.
Derivation: why the gaps add up to zero
The expected frequencies are built to have the same total as the observed ones.
Subtracting one sum from the other shows that the gaps cancel.
So once all but one gap is known, the last gap is fixed, and one degree of freedom is lost.
Degrees of freedom move the curve
The diagram shows chi-squared curves for different degrees of freedom. With more degrees of freedom the curve moves to the right, so larger statistics become ordinary. This is why the critical value grows with the degrees of freedom. A statistic of 8 might be significant with 2 degrees of freedom but entirely typical with 6.
Significance levels and errors
The significance level is the probability of rejecting a model that is in fact correct. A 5% level means that a correct model would be wrongly rejected about one time in twenty. A stricter 1% level reduces that risk but makes it harder to detect a model that is wrong. Choose the level before looking at the data.
Worked example 3: deciding about the die
For the die in worked example 1, carry out the test at the 5% level.
| Working | Reason |
|---|---|
| , since nothing was estimated | Subtract one for the fixed total |
| Critical value | Read the table for five degrees of freedom |
| : do not reject; no evidence the die is biased | Compare and conclude in context |
Tables, calculators and accuracy
Tables give critical values to three decimal places, which is plenty for a decision. A calculator can give the exact upper-tail probability instead. Either method is acceptable, but state which value is being compared. When the statistic is very close to the critical value, keep extra accuracy in the working so that rounding cannot change the decision.
Thinking about what the classes mean
Before calculating, look at the observed and expected columns side by side. Large differences in particular classes often suggest what is wrong with a model. For example, too many zeros compared with a Poisson model suggests that some units never produce events. This kind of thinking turns a mechanical test into a real investigation of the data.
Worked example 4: an estimated parameter
A Poisson model is fitted to data in 4 classes, with the rate estimated from the data. Find the degrees of freedom and the 5% critical value.
| Working | Reason |
|---|---|
| Classes 4, estimated parameters 1 | Count both before subtracting |
| Subtract one for the total and one for the rate | |
| Critical value | Read the table for two degrees of freedom |
Check yourself. State the critical value for a chi-squared test with 3 degrees of freedom at the 1% level.
Show the answer
From the tables, . Notice that this is much larger than the 5% value of 7.815, because a stricter test needs stronger evidence.
Section 3
Small expected frequencies
The rule of 5
The chi-squared approximation is unreliable when expected frequencies are small. A common rule is that every expected frequency should be at least 5. If some are smaller, pool them with neighbouring classes until the rule holds. Pool the observed frequencies for the same classes too, so that observed and expected still match.
Common mistake: pooling classes by their observed frequencies instead of their expected ones. The rule concerns the expected frequencies, because they appear in the denominators. A class with a small observed frequency but a large expected frequency does not need pooling. Always decide on pooling from the expected column.
Which classes to pool
Pool neighbouring classes, usually in the tails where expected frequencies are small. Start from the end and combine until the total reaches 5. Do not pool classes that are far apart, because that would hide the shape of the distribution. Record the pooled classes clearly, for example as a class of 3 or more.
Pooling reduces degrees of freedom
Each pooling reduces the number of classes by one, and so reduces the degrees of freedom. Count the classes after pooling, not before. This is a frequent source of error in examinations. Writing the final table of observed and expected frequencies, after pooling, makes the count clear.
Why small expected frequencies cause trouble
A small expected frequency appears in a denominator. If the observed frequency happens to be even slightly larger, the contribution becomes huge. This one class can then dominate the statistic, giving a misleading result. The chi-squared distribution is only an approximation, and it fails when expected frequencies are too small.
Pool before you calculate
Pooling must happen before the contributions are calculated. Work out every expected frequency first, decide which classes to pool, and then build the final table. Calculating contributions for small classes and adding them afterwards defeats the purpose. The final table should be the one used for the statistic, the degrees of freedom and the conclusion.
Pooling in the middle
Small expected frequencies usually appear in the tails, but not always. A uniform model with few observations may have small expected frequencies everywhere. Then neighbouring classes can be combined throughout, such as grouping the faces of a die in pairs. The rule is the same: combine neighbours until every expected frequency reaches five.
Pooling loses detail
Every pooling hides some detail about the shape of the data. Pooling the tail of a Poisson model, for example, means the test cannot see whether large counts are too common. This is a price paid for a reliable approximation. Pool only as much as the rule requires, and no more.
Worked example 5: pooling a Poisson tail
Goals in 100 matches were 0, 1, 2, 3 and 4 or more with frequencies 30, 36, 22, 9 and 3. A Poisson model with rate 1.19 gives expected frequencies 30.42, 36.20, 21.54, 8.54 and 3.29. Pool where necessary and find the statistic.
| Working | Reason |
|---|---|
| Pool 3 and 4 or more: observed 12, expected 11.84 | The last expected frequency is below five |
| Find each contribution after pooling | |
| Add the four contributions |
Recording the pooled table
After pooling, write out the final classes with their observed and expected frequencies side by side. Label pooled classes clearly, such as 2 or more. This table is what the examiner marks, and it makes the count of classes obvious. It also shows that every expected frequency now meets the rule, which earns credit.
Worked example 6: pooling a binomial tail
Fifty sets of four trials, each with success probability 0.2, gave 0, 1, 2, 3 and 4 successes with frequencies 18, 22, 8, 2 and 0. Pool the classes so every expected frequency is at least 5.
| Working | Reason |
|---|---|
| Expected: gives 20.48, 20.48, 7.68, 1.28, 0.08 | Multiply the binomial probabilities by fifty |
| Pool 2, 3 and 4: expected 9.04, observed 10 | Combine the tail until it reaches five |
| Final classes 0, 1, 2 or more: O = 18, 22, 10 and E = 20.48, 20.48, 9.04 | List the table after pooling |
Check yourself. A model is fitted to 60 observations. The expected frequencies for 0, 1, 2 and 3 or more are 26.96, 21.57, 8.63 and 2.85. The observed frequencies are 25, 24, 8 and 3. Pool where necessary.
Show the answer
The last expected frequency, 2.85, is below 5, so pool it with the class before. The table becomes 0, 1 and 2 or more, with observed 25, 24 and 11 and expected 26.96, 21.57 and 11.47.
Section 4
Fitting standard distributions
Expected frequencies from a model
To test a standard model, find the probability of each class and multiply by the total number of observations. For a uniform model, every class has the same probability. For binomial, Poisson and geometric models, use their formulas. The last class must collect all remaining values so that the probabilities add up to 1.
Common mistake: using the class probabilities as the expected values. The expected frequency is the probability multiplied by the total number of observations. Using the probability alone gives tiny numbers that cannot be compared with counts, and the statistic becomes enormous.
Estimating parameters
Sometimes the model's parameter is given, as in testing whether a coin is fair. Often it must be estimated from the data. Estimate a Poisson rate by the sample mean. Estimate a binomial probability by the sample mean divided by the number of trials. Estimate a geometric probability by one over the sample mean. Each estimate costs one degree of freedom.
Specified models
A null hypothesis may specify a model completely, such as a die is fair or the ratio of types is 9 to 3 to 3 to 1. Then no parameters are estimated, and the degrees of freedom are simply the number of classes minus one. Such tests are common in genetics, where theory predicts exact ratios of offspring types.
Describing the model in the hypotheses
Write the hypotheses in terms of the model. For example, the number of goals per match can be modelled by a Poisson distribution. If the parameter is specified, include it, such as a Poisson distribution with mean 1.5. The alternative is simply that the model is not suitable. Clear hypotheses make the rest of the test easy to follow.
Why estimates cost freedom
When a parameter is estimated from the data, the fitted model is pulled towards the observations. The expected frequencies then sit closer to the observed ones than a model fixed in advance would. That makes the statistic smaller on average. Removing a degree of freedom for each estimate lowers the critical value to match, keeping the test fair.
Choosing the last class
The final class must collect every remaining value, such as 4 or more for a Poisson model. Its probability is one minus the sum of the others. Leaving it out makes the expected frequencies add up to less than the total. That is one of the most common errors in goodness-of-fit questions, and the total check catches it.
Continuous data in classes
The test can also be used for continuous data, such as times or lengths, once they are grouped into intervals. The model then gives the probability of each interval. The same rules apply: expected frequencies of at least five, and a degree of freedom lost for each estimated parameter. The test is flexible because it only ever compares counts.
Worked example 7: estimating a binomial probability
For the three coins in worked example 2, estimate from the data and find the expected frequencies and degrees of freedom.
| Working | Reason |
|---|---|
| Mean , so | Estimate p as the mean over three |
| Expected: 8.57, 28.43, 31.42, 11.58 | Use the binomial model with the estimate |
| , statistic 2.252 | One degree of freedom is lost to the estimate |
Checking a model's assumptions first
Before testing a model, ask whether its conditions are plausible. A Poisson model needs events that occur singly, independently and at a constant rate. A binomial model needs a fixed number of independent trials with the same probability. If the conditions clearly fail, the test is likely to reject the model, and the reason is already known.
Worked example 8: testing the Poisson fit
For the goals data in worked example 5, test at the 5% level whether a Poisson model fits.
| Working | Reason |
|---|---|
| : goals follow a Poisson distribution; rate estimated as 1.19 | State the model and the estimate |
| After pooling, 4 classes, so , critical value 5.991 | Count classes after pooling |
| : do not reject; a Poisson model is suitable | Compare and conclude in context |
Check yourself. Using classes 0, 1, 2, 3 and 4 or more, work out the expected frequencies for with 50 observations.
Show the answer
Multiplying the Poisson probabilities by 50 gives 6.77, 13.53, 13.53 and 9.02 for 0 to 3. The class 4 or more takes the remainder, 7.14, so the five expected frequencies add up to 50.
Section 5
Contingency tables
Testing independence
A contingency table counts observations classified by two factors, such as gender and preferred subject. The null hypothesis is that the two factors are independent. Under independence, the expected frequency in each cell is
The statistic is over all cells, with degrees of freedom for rows and columns.
Common mistake: using rc − 1 degrees of freedom. The expected frequencies are built from the row and column totals, which fixes many cells once a few are chosen. Only cells are free. Using gives a critical value that is far too large.
Testing independence in a contingency table
- Statistic
- 4
- ν = (r − 1)(c − 1)
- 2
- Critical value at 5%
- 5.991
- Decision
- do not reject H₀
Figure 43.3 shows a table whose association can be strengthened with a slider. The wrong model's critical value, with degrees of freedom, hides even strong associations.
Derivation: expected frequencies under independence
If the factors are independent, the probability that an observation falls in row i and column j is the product of the separate probabilities, estimated from the totals.
Multiplying by the grand total n gives the expected frequency for the cell.
So each expected frequency is its row total times its column total over the grand total.
Why (r − 1)(c − 1)?
In each row, once all but one cell are known, the row total fixes the last one. The same applies to each column. So in a table of rows and columns, filling the first rows and columns fixes everything else. That leaves free cells, which is the number of degrees of freedom.
Small expected frequencies in tables
The rule of 5 also applies to contingency tables. If some expected frequencies are small, combine rows or columns where it makes sense, such as merging two similar categories. Then recalculate the expected frequencies and the degrees of freedom. As before, the decision to combine is based on expected, not observed, frequencies.
Reading a contingency table
Each cell counts observations with one level of the first factor and one level of the second. The row totals count each level of the first factor, and the column totals count each level of the second. The grand total is the number of observations. Writing all the totals around the edge of the table makes the expected frequencies quick to find.
Expected frequencies follow the totals
Under independence, each row splits in the same proportions as the column totals. If half of all observations fall in the first column, then half of each row is expected there. This is why the expected frequencies use the row and column totals. A table of expected frequencies always has exactly the same totals as the observed table.
A check on the expected table
After finding the expected frequencies, add each row and each column. The totals should match the observed totals exactly. If they do not, an arithmetic slip has occurred. The check takes seconds and prevents a wrong statistic, so it is worth doing in every contingency question.
Worked example 9: expected frequencies
Two groups, A and B, choose among three options. Group A chose them 30, 20 and 10 times, and group B 20, 30 and 40 times. Find the expected frequencies under independence.
| Working | Reason |
|---|---|
| Row totals 60 and 90; column totals 50, 50, 50; grand total 150 | Add along each row and down each column |
| Row A: in each cell | Row total times column total over grand total |
| Row B: in each cell | Repeat for the second row |
Choosing which factor is rows
It does not matter which factor goes in the rows and which in the columns. The expected frequencies, the statistic and the degrees of freedom all come out the same. Choose whichever layout is easiest to read. The conclusion should still describe the association in terms of both factors and the context.
Worked example 10: the test
For the table in worked example 9, test at the 5% level whether choice is independent of group.
| Working | Reason |
|---|---|
| Add the six contributions | |
| , critical value 5.991 | Use rows minus one times columns minus one |
| : reject; evidence that choice depends on group | Compare and conclude in context |
Check yourself. A 2 by 2 table has observed frequencies 40, 10 in the first row and 30, 20 in the second. Find the statistic.
Show the answer
The totals give expected frequencies 35, 15, 35 and 15. Every cell has a gap of 5, so the statistic is , on 1 degree of freedom.
Section 6
Interpreting results
Looking at contributions
When a test rejects the null hypothesis, the contributions show where the disagreement lies. Find the largest contributions and compare observed with expected in those cells. This tells you the nature of the difference, such as group A choosing the first option more often than expected. A good conclusion describes this pattern in context.
Common mistake: concluding that one factor causes the other. A significant test shows association, not causation. Group and choice may be linked through some third factor, or the link may run in either direction. State that there is evidence of an association, and avoid claiming that one factor causes the other.
p-values for chi-squared tests
A calculator can give the p-value directly, as the probability that a chi-squared variable exceeds the observed statistic. Compare it with the significance level. Reporting the p-value shows the strength of the evidence: a very small p-value is strong evidence of a poor fit or an association.
Sample size and significance
With very large samples, even tiny departures from a model become significant. With small samples, even large departures may not be. So a significant result does not always mean an important difference, and a non-significant result does not prove the model is right. Consider the size of the differences as well as the test result.
Assumptions of the test
The test assumes the observations are independent and that each falls into exactly one class. It also needs the expected frequencies to be large enough, hence the rule of 5. Repeated measurements on the same people, or classes that overlap, break these assumptions. Checking them is part of using the test properly.
Describing the direction
A conclusion should say which way the difference goes, not just that there is one. Compare observed and expected frequencies in the cells with the largest contributions. If observed is higher than expected, that combination happens more often than independence predicts. If observed is lower, it happens less often. This gives a meaningful description in context.
Writing a conclusion in context
A good conclusion uses the words of the problem. Instead of rejecting the null hypothesis alone, say that there is evidence that support for the proposal depends on the area. Avoid saying that something is proved. Statistical tests give evidence, and the language of the conclusion should reflect that uncertainty.
When the fit is too good
A very small statistic, far below its mean, means the data fit the model unusually closely. This can happen by chance. It can also suggest that data were adjusted to match a theory. Some historical genetics results have been questioned for fitting too well. The usual test ignores this lower tail, but it is worth noticing.
Worked example 11: where is the association?
Using the contributions for the table in worked example 10, describe the association.
| Working | Reason |
|---|---|
| Largest contributions: A1 and A3, each 5 | Identify the cells driving the statistic |
| A1: observed 30, expected 20; A3: observed 10, expected 20 | Compare observed with expected in those cells |
| Group A favours option 1 and avoids option 3, relative to independence | Describe the pattern in context |
Reporting a test fully
A complete report gives the hypotheses, the table of observed and expected frequencies, the statistic, the degrees of freedom, the critical value or p-value, and a conclusion in context. Leaving out any of these makes the result hard to check. In an examination, each part usually carries its own mark, so a full report protects every one.
Worked example 12: a p-value
Find the p-value for the statistic 16.67 on 2 degrees of freedom, and interpret it.
| Working | Reason |
|---|---|
| p-value | The test uses the upper tail |
| Evaluate with a calculator | |
| Far below 1%: very strong evidence of an association | Interpret the size of the p-value |
Check yourself. Calculate the p-value for the die in worked example 1, with statistic 4.1 on 5 degrees of freedom.
Show the answer
The p-value is . This is very large, so the data are entirely consistent with a fair die.
Reference
Results in this chapter
| Result | What it says | When to use it | In the formula booklet? |
|---|---|---|---|
| The test statistic | Every chi-squared test | Yes | |
| Goodness-of-fit degrees of freedom | Fitting a model | No, learn it | |
| Expected at least 5 | Pooling rule | Small expected frequencies | No, learn it |
| Expected frequency | Fitting a model | No, learn it | |
| Expected under independence | Contingency tables | No, learn it | |
| Contingency degrees of freedom | Independence tests | No, learn it |
Reasoning
Proof workshop: equal gaps in a 2 by 2 table
The claim
In a 2 by 2 contingency table, the gap has the same size in all four cells, with the signs alternating. So the table has one degree of freedom.
Strategy
Let the table have observed frequencies , in the first row and , in the second, with grand total . Calculate for the top-left cell using the expected frequency formula. Then use the fact that the expected frequencies have the same row and column totals as the observed ones to find the other gaps.
The key insight is that the gaps in each row add up to zero, because observed and expected rows have the same totals. The same is true of each column. In a 2 by 2 table, this forces all four gaps to be equal in size.
The proof
For the top-left cell, with row total and column total ,
Since the gaps in the first row add to zero, the top-right gap is . The columns then give the bottom row:
So every gap has size , and fixing one cell fixes them all.
Checking every step
Expanding gives . The row and column sums of the gaps are zero because each expected row or column has the same total as the observed one.
A numerical check uses the check-yourself table with 40, 10, 30 and 20. Here and , so every gap has size 5. The expected frequencies were 35, 15, 35 and 15, and the gaps were indeed .
This proof shows why a 2 by 2 table has exactly one degree of freedom: one number, , determines every gap. It also gives a quick formula for the statistic in this case.
Your turn
For the 2 by 2 table with first row 10, 20 and second row 30, 40, find and hence the size of each gap .
Show a model proof
Here and . So every gap has size 2, which matches the expected frequencies 12, 18, 28 and 42 against the observed 10, 20, 30 and 40.
Practice
Practice ladder
Rung 1: Recall and fluency
Q1. Three classes have observed frequencies 12, 18 and 30, and each has expected frequency 20. Calculate the statistic.
Worked solution to Q1
The gaps are , and 10, so the squared gaps are 64, 4 and 100. Dividing each by 20 and adding gives .
Q2. State the 5% critical value for 4 degrees of freedom.
Worked solution to Q2
Reading the row for 4 degrees of freedom in the 5% column of the tables gives . A statistic above this value would lead to rejecting the null hypothesis.
Q3. A model with 2 estimated parameters is fitted to data in 7 classes. Write down the degrees of freedom.
Worked solution to Q3
Subtract one for the fixed total and one for each estimated parameter. So degrees of freedom.
Rung 2: Application
Q4. Find the expected frequencies for the number of heads when two fair coins are tossed 60 times.
Worked solution to Q4
The number of heads is , with probabilities , and . Multiplying by 60 gives expected frequencies of 15, 30 and 15.
Q5. Carry out the pooling for the table in the check-yourself of section 3, and say how many classes remain.
Worked solution to Q5
The final class has expected frequency 2.85, which is below 5, so it is pooled with the class before. That leaves three classes, with observed 25, 24 and 11 and expected 26.96, 21.57 and 11.47.
Q6. Determine the expected frequencies under independence for the 2 by 2 table with first row 10, 20 and second row 30, 40.
Worked solution to Q6
The row totals are 30 and 70, the column totals 40 and 60, and the grand total 100. Each expected frequency is row total times column total over 100, giving 12, 18, 28 and 42.
Rung 3: Analysis
Q7. Using your answer to Q6, evaluate the statistic and state the degrees of freedom.
Worked solution to Q7
Every gap has size 2, so the statistic is . A 2 by 2 table has degree of freedom.
Q8. Calculate the expected frequencies for a geometric model with and 200 observations, using classes 1, 2, 3 and 4 or more.
Worked solution to Q8
The probabilities for 1, 2 and 3 are 0.3, 0.21 and 0.147, and the class 4 or more takes . Multiplying by 200 gives 60, 42, 29.4 and 68.6.
Q9. Find the p-value for the statistic in Q1, with 2 degrees of freedom, and decide at the 5% level.
Worked solution to Q9
The p-value is . This is below 0.05, so the data provide evidence against the model of equal frequencies.
Rung 4: Stretch
Q10. A die is rolled 60 times, giving 8, 12, 10, 14, 6 and 10. Test at the 5% level whether it is fair.
Worked solution to Q10
Each expected frequency is 10, and the statistic is on 5 degrees of freedom. Since , there is no evidence that the die is biased.
Q11. How many degrees of freedom does a contingency table with 3 rows and 3 columns have? Explain.
Worked solution to Q11
Once the first two rows and first two columns are filled, the row and column totals fix the rest. So there are free cells, giving 4 degrees of freedom.
Q12. The counts 0, 1, 2 and 3 occurred 20, 15, 10 and 5 times. Estimate the Poisson rate for a goodness-of-fit test.
Worked solution to Q12
The rate is estimated by the sample mean. That is , so the fitted model is , costing one degree of freedom.
Exam practice
Exam technique and worked answer workshop
How these questions are marked
B1 marks go to hypotheses in words and to expected frequencies. M1 marks go to pooling correctly, using , counting degrees of freedom and comparing with the critical value. A1 marks go to the statistic, the critical value and a conclusion in context.
Lay out a table of observed and expected frequencies, after pooling, with a column of contributions. State the degrees of freedom with a reason, such as one lost for the estimated rate. Finish with a conclusion in context.
Exam question 1 (6 marks · Paper 3 · about 8 minutes)
A die is rolled 120 times, giving the scores 1 to 6 with frequencies 15, 22, 18, 26, 17 and 22. Test, at the 5% level, whether the die is fair. (6)
Mark scheme for exam question 1
: the die is fair; : it is not B1
Expected frequency 20 for each score B1
M1
A1
, critical value 11.070 M1
Do not reject: no evidence the die is biased A1
Exam question 2 (6 marks · Paper 3 · about 8 minutes)
Three coins are tossed 80 times, and the numbers of heads 0, 1, 2 and 3 occur 6, 34, 28 and 12 times. Test, at the 5% level, whether the coins are fair. (6)
Mark scheme for exam question 2
: is a suitable model B1
Expected 10, 30, 30, 10 B1
M1
A1
, critical value 7.815 M1
Do not reject: no evidence the coins are biased A1
Exam question 3 (7 marks · Paper 3 · about 10 minutes)
The numbers of goals in 100 matches were 0, 1, 2, 3 and 4 or more with frequencies 30, 36, 22, 9 and 3. Test, at the 5% level, whether a Poisson model is suitable. (7)
Mark scheme for exam question 3
Estimate B1
Expected 30.42, 36.20, 21.54, 8.54, 3.29 M1
Pools the last two classes M1
A1
M1
Critical value 5.991 A1
Do not reject: a Poisson model is suitable A1
Exam question 4 (6 marks · Paper 3 · about 8 minutes)
Group A chose three options 30, 20 and 10 times, and group B chose them 20, 30 and 40 times. Test, at the 5% level, whether choice is independent of group. (6)
Mark scheme for exam question 4
: choice and group are independent B1
Expected 20, 20, 20 and 30, 30, 30 M1
A1
B1
Critical value 5.991 M1
Reject: evidence of an association between group and choice A1
Exam question 5 (6 marks · Paper 3 · about 8 minutes)
In a survey, 40 of 50 people in one area and 30 of 50 in another support a proposal; the rest do not. Test, at the 5% level, whether support is independent of area. (6)
Mark scheme for exam question 5
: support is independent of area B1
Expected 35, 15, 35, 15 M1
A1
B1
Critical value 3.841 M1
Reject: evidence that support depends on area A1
Exam question 6 (6 marks · Paper 3 · about 8 minutes)
Show that a contingency table with rows and columns has degrees of freedom, explaining the role of the row and column totals. (6)
Mark scheme for exam question 6
Expected frequencies use the row and column totals B1
Observed and expected rows have equal totals M1
So the last cell of each row is fixed A1
Similarly the last cell of each column is fixed M1
Free cells form an by block A1
So A1
Exam question 7 (7 marks · Paper 3 · about 10 minutes)
A driving school counted the attempts its 100 pupils needed to pass. Exactly 1, 2, 3, 4 and 5 or more attempts were needed 44, 20, 16, 8 and 12 times. Test, at the 5% level, whether is a suitable model. (7)
Mark scheme for exam question 7
: is a suitable model B1
Expected 40, 24, 14.4, 8.64, 12.96 M1
All expected at least 5 B1
A1
M1
Critical value 9.488 A1
Do not reject: the model is suitable A1
Exam question 8 (6 marks · Paper 3 · about 8 minutes)
Fifty sets of four trials, each with success probability 0.2, gave 0, 1, 2, 3 and 4 successes with frequencies 18, 22, 8, 2 and 0. Test, at the 5% level, whether is a suitable model. (6)
Mark scheme for exam question 8
Expected 20.48, 20.48, 7.68, 1.28, 0.08 B1
Pools the last three classes M1
A1
M1
Critical value 5.991 A1
Do not reject: the model is suitable A1
Annotated model answer: exam question 3
The null hypothesis is that goals per match follow a Poisson distribution. The rate is estimated by the sample mean, . B1. Multiplying the probabilities by 100 gives expected frequencies 30.42, 36.20, 21.54, 8.54 and 3.29. M1.
The last expected frequency is below 5, so the last two classes are pooled into 3 or more, with observed 12 and expected 11.84. M1. The statistic is then 0.0191. A1. With 4 classes and one estimated parameter, , and the critical value is 5.991. M1 A1. Since , do not reject: a Poisson model is suitable for the number of goals. A1.
Annotated model answer: exam question 4
The null hypothesis is that the choice of option is independent of group. B1. The row totals are 60 and 90, and each column total is 50, out of 150. So the expected frequencies are 20 in each cell of row A and 30 in each cell of row B. M1.
The statistic is . A1. There are degrees of freedom, with critical value 5.991. B1 M1. Since , reject the null hypothesis: there is evidence of an association between group and choice, with group A favouring the first option. A1.
Connections
Synoptic link
The Poisson distribution and Geometric and negative binomial distributions supply the models whose fit is tested here. Hypothesis tests for Poisson and geometric models introduced the language of hypotheses, significance levels and conclusions used throughout.
Tests for variances: chi-squared and F uses the chi-squared distribution in a different way, to test the variance of a normal population. Probability generating functions offers another way to identify the distribution of counts before testing it.
Synoptic question 1. The mean of a chi-squared distribution with degrees of freedom is . Explain why a statistic of 4.1 on 5 degrees of freedom is unremarkable, without using tables.
Answer to synoptic question 1
If the model is true, the statistic has mean 5, so values near 5 are typical. A value of 4.1 is slightly below the mean, which is entirely ordinary, so it gives no evidence against the model.
Recap
Recap and next step
- The statistic is , with expected frequencies from the model.
- Degrees of freedom are classes minus one minus the number of estimated parameters.
- Pool classes until every expected frequency is at least 5, and count the classes after pooling.
- Expected frequencies are the model's probabilities times the total.
- In a contingency table, and .
- Use the contributions to describe any association, and do not claim causation.
Next chapter: Probability generating functions, which package a whole distribution into one function and make means, variances and sums easy to find.
For your exam board
This chapter covers Pearson Edexcel A Level Further Mathematics (9FM0) Further Statistics 1 section 6: chi-squared goodness-of-fit tests for discrete uniform, binomial, Poisson and geometric models, and tests of independence in contingency tables, including degrees of freedom and pooling of classes. It is assessed on Paper 3B, Further Statistics 1. Similar content appears in AQA (7367) and OCR (H245) statistics options.