S5.2.4 Chapter 4
Testing results with chi squared
A cross should give 3 round seeds for every 1 wrinkled seed, but a gardener counts 84 round and 36 wrinkled. Is that close enough, or is the ratio wrong?
Your guess
Pick one before you read on. It is fine to be wrong.
By the end you can
- Use the chi squared test to compare observed and expected ratios
- Interpret a p value and state a conclusion
A cross predicts a ratio, such as 3 : 1. The ratio is a chance for each offspring, not a promise for a small group. A real count never matches it exactly. The observed counts are the ones we find. The expected counts are the ones the ratio predicts.
To work out an expected count, divide the total in proportion to the ratio. With 120 offspring and a ratio of 3 : 1, the parts are 3 + 1 = 4. The expected counts are 3/4 × 120 = 90 and 1/4 × 120 = 30.
The question is how far apart the observed and expected counts may be before we stop blaming chance. The chi squared test, written χ², answers it. It starts with a null hypothesis: the difference between the counts and the ratio is due to chance alone.
The statistic is χ² = Σ (O − E)² ÷ E. For each class, take the observed count O minus the expected count E, square it, and divide by E. Then add up the classes. The square makes every gap positive, and dividing by E makes a gap matter more where the expected count is small.
The degrees of freedom, df, is the number of classes minus 1. With a 3 : 1 ratio there are 2 classes, so df = 1. With a 9 : 3 : 3 : 1 ratio there are 4 classes, so df = 3. Once all but one of the counts are known, the last one is fixed by the total, so it is not free.
Each df has a critical value. If χ² is smaller than the critical value at p = 0.05, the gap is small enough that chance alone would make it more than 1 time in 20. We call the difference not significant. If χ² is equal to it or larger, the gap is significant: chance alone would make a gap this big less than 1 time in 20.
Worked example
A gardener counts 84 round seeds and 36 wrinkled seeds from a cross that should give 3 : 1. Test the ratio at the 5% level.
- The null hypothesis is that the counts fit 3 : 1. The total is 120, so the expected counts are 90 and 30.
- Round: (84 − 90)² ÷ 90 = 36 ÷ 90 = 0.4. Wrinkled: (36 − 30)² ÷ 30 = 36 ÷ 30 = 1.2.
- χ² = 0.4 + 1.2 = 1.6.
- There are 2 classes, so df = 1. The critical value at 0.05 is 3.841.
- 1.6 is less than 3.841, so the difference is not significant. The counts fit a 3 : 1 ratio.
Answer: 1.6
The p value is the chance of getting a gap at least as big as the one seen, if the null hypothesis is true. For χ² = 1.6 with df = 1, the p value is about 0.21. That is more than 0.05, so the same decision follows: the counts fit the ratio.
Worked example
Mendel counted 315, 108, 101 and 32 seeds in the four classes of a dihybrid cross. Test them against 9 : 3 : 3 : 1.
- The total is 556. The expected counts are 312.75, 104.25, 104.25 and 34.75.
- The parts of χ² are 0.016, 0.135, 0.101 and 0.218.
- χ² = 0.470 to three decimal places.
- There are 4 classes, so df = 3 and the critical value at 0.05 is 7.815.
- 0.470 is far below 7.815. The counts fit 9 : 3 : 3 : 1.
Answer: 0.47
Worked example
In chapter 3, a test cross of fruit flies gave 965, 944, 206 and 185 offspring. If the two genes were on different chromosomes the ratio would be 1 : 1 : 1 : 1. Test it.
- The total is 2300, so the expected count in each class is 575.
- The parts are 264.5, 236.8, 236.8 and 264.5.
- χ² = 1002.6 to one decimal place.
- There are 4 classes, so df = 3 and the critical value at 0.05 is 7.815.
- 1002.6 is far above 7.815, so the difference is significant. The genes do not sort on their own: they are linked.
Answer: 1002.6
Write a conclusion in words and always link it to the null hypothesis. If χ² is less than the critical value, write that there is no significant difference between the observed and expected counts, so the results fit the ratio.
If χ² is larger than the critical value, write that there is a significant difference. The results do not fit the ratio, and something other than chance is probably acting.
Be careful about three things. Use counts, never percentages: 55 of 100 and 550 of 1000 are the same percentage, but 550 of 1000 is much stronger evidence. Each expected count should be at least 5, or the test is unreliable. And the classes must be separate, so each offspring is counted once.
See it three ways
As a picture
In words
The gardener's result, 1.6, lies to the left of the critical value, outside the hatched tail. Chance alone could often give a gap this big. A result in the tail would be rare.
In symbols
χ² = Σ (O − E)² ÷ E. For df = 1, the critical value is 3.841. 1.6 is below it, so the difference is not significant.
Try it
Test a coin
You need: a coin, a piece of paper, a pencil.
- Toss the coin 40 times. Count the heads and the tails.
- If the coin is fair, the null hypothesis is that heads and tails are equally likely, so the expected counts are 20 and 20.
- Work out (O − E)² ÷ E for heads, and for tails, and add them to get χ².
- There are 2 classes, so df = 1. Compare χ² with 3.841.
What you will see: Almost every fair coin passes: about 19 coins in 20 give a χ² below 3.841. A coin that gives 23 heads and 17 tails has χ² = 0.9, which is nowhere near the critical value.
A wrong idea many people have
If χ² is below the critical value, the ratio is proved right.
Why it feels right: The test says the difference is not significant, which sounds like the counts match the ratio exactly.
The test that breaks it: Take 20 seeds with 13 round and 7 wrinkled. Against 3 : 1, χ² is 1.07. Against 1 : 1, χ² is 1.8. Both are below 3.841, so both ratios fit. A small count cannot tell them apart, so passing the test proves nothing.
What is true: A result that is not significant means there is no evidence against the ratio. It does not prove the ratio. More counts could change the result.
Key words
- observed
- the counts that were found.
- expected
- the counts that the ratio predicts, from the total.
- null hypothesis
- the statement that the difference between observed and expected is due to chance alone.
- chi squared test
- a test that compares observed and expected counts, using χ² = Σ (O − E)² ÷ E.
- degrees of freedom
- the number of classes minus 1.
- critical value
- the value of χ² that chance alone gives only 1 time in 20 at p = 0.05.
- significant
- too big a difference to be explained by chance alone, at the level chosen.
- p value
- the chance of a gap as big as the one seen, if the null hypothesis is true.
Back to your guess
The answer is D: We cannot say from the ratio alone. We need a test that shows how often chance would make a gap this big.
Chance never gives an exact ratio. The chi squared test measures the gap between the counts and the ratio, and says how often chance alone would give a gap as big.
Check yourself
Try each one before you look. A wrong answer tells you where to go next.
A cross gives four classes of offspring, which should be in the ratio 9 : 3 : 3 : 1. How many degrees of freedom does the test have?
See the answer
3
There are 4 classes, so df = 4 − 1 = 3.
- If you chose A: 4 is the number of classes. The degrees of freedom is one less, because the last count is fixed by the total. Read this page again.
- If you chose B: 1 would be right for two classes. Here there are four. Read this page again.
- If you chose C: 16 is the number of boxes in the square, not the number of classes. Read this page again.
A 3 : 1 cross gives 18 round and 12 wrinkled seeds, 30 in all. What is χ²?
See the answer
3.6
The expected counts are 22.5 and 7.5. (18 − 22.5)² ÷ 22.5 = 0.9 and (12 − 7.5)² ÷ 7.5 = 2.7. 0.9 + 2.7 = 3.6.
A test with 1 degree of freedom gives χ² = 1.6. The critical value at 0.05 is 3.841. What is the conclusion?
See the answer
The difference is not significant, so the counts fit the ratio.
1.6 is less than 3.841. Chance alone could often make a gap this big, so there is no evidence against the ratio.
- If you chose A: A difference is significant only when χ² is at least the critical value. 1.6 is less than 3.841. Read this page again.
- If you chose C: A test cannot prove a ratio right. It can only say there is no evidence against it. Read this page again.
A dihybrid cross gives χ² = 12.4 with 3 degrees of freedom. The critical value at 0.05 is 7.815. What is the conclusion?
See the answer
The difference is significant, so the results do not fit 9 : 3 : 3 : 1.
12.4 is larger than 7.815, so chance alone would make a gap this big less than 1 time in 20.
- If you chose A: 12.4 is larger than 7.815, so the difference is significant. Read this page again.
- If you chose B: A χ² of 0 would mean exactly as predicted. 12.4 is a large gap. Read this page again.
- If you chose D: The test works with any number of degrees of freedom. Only the critical value changes. Read this page again.
A test gives a p value of 0.03. Which statement is correct?
See the answer
If the ratio is right, a gap this big would happen about 3 times in 100.
A p value is the chance of results at least this far from expected, if the null hypothesis is true. 0.03 is 3 in 100, and it is below 0.05, so the result is significant.
- If you chose A: The p value is not the chance that the ratio is right. It is the chance of a gap this big if the ratio is right. Read this page again.
- If you chose C: The p value says nothing about how often the ratio is right. It is about the chance of the gap, if the ratio is right. Read this page again.
From an earlier chapter
Two RrYy plants are crossed and give 320 seeds. About how many are expected to be round and green?
Mendel counted 5 474 round and 1 850 wrinkled seeds, 7 324 in all. The expected counts for 3 : 1 are 5 493 and 1 831. What is χ², to 2 decimal places?
See the answer
0.26
(5 474 − 5 493)² ÷ 5 493 = 361 ÷ 5 493 = 0.066. (1 850 − 1 831)² ÷ 1 831 = 361 ÷ 1 831 = 0.197. The sum is 0.263, or 0.26.
A cross should give a ratio of 1 : 1 and 40 offspring are counted, 24 of one kind and 16 of the other. What is χ²?
See the answer
1.6
The expected counts are 20 and 20. (24 − 20)² ÷ 20 = 0.8 and (16 − 20)² ÷ 20 = 0.8. The sum is 1.6.
Look at the table of critical values. What is the critical value at 0.01 for 2 degrees of freedom?
See the answer
9.210
Read the row for df = 2 and the column 0.01. The value is 9.210.
- If you chose A: 5.991 is for 2 degrees of freedom at 0.05, not at 0.01. Read this page again.
- If you chose B: 6.635 is for 1 degree of freedom at 0.01. The row for 2 degrees of freedom is the second row. Read this page again.
- If you chose D: 11.345 is for 3 degrees of freedom at 0.01. Read this page again.
Look at the table of two samples of seeds. Against a 1 : 1 ratio, in which sample is the difference significant at the 5% level?
See the answer
The sample of 100 seeds
For 60 and 40 the expected counts are 50 and 50. The parts are 2 and 2, so χ² is 4, which is above 3.841. The sample of 1000 has a gap of 20 in 500, and its χ² is only 1.6. A small sample can be significant when its gap is wide enough.
- If you chose B: For 520 and 480 the expected counts are 500 and 500. The parts are 0.8 and 0.8, so χ² is 1.6, which is below 3.841. Read this page again.
- If you chose C: Only one of them is. The sample of 1000 gives χ² = 1.6, which is below 3.841. Read this page again.
Keep it
Copy this into your exercise book.
χ² = Σ (O − E)² ÷ E. Degrees of freedom are the classes minus 1. Below the critical value at 0.05, the difference is not significant. At or above it, it is significant. Use counts.
Draw: A curve with the right tail hatched and a dashed line at the critical value.