# Chi-squared test

###### The **Chi-squared test** (or goodness of fit) is a test to determine if the observed results deviate too far from a theoretical expectation.

Fit means how closely the observed results agree with the expected results. To measure the goodness of fit, we use the Chi-square test. In research, it is often necessary to compare experimentally observed numbers of items in several categories with numbers that are predicted on the basis of some hypothesis. Genetic analysis often requires the interpretation of numbers in various phenotypic classes.

- Look up the Χ
^{2}table to find the closest p-value for the Χ^{2}number you obtained and the corresponding degree of freedom. - The p-value is the probability that a worse fit would be obtained by chance, assuming that the hypothesis is true.
- If the hypothesis is true, then the observed numbers should be reasonably close to the expected numbers, and the Χ
^{2}value is small. - If the hypothesis is not true when the observed numbers deviate too much from and expected numbers and the Χ
^{2}value is large. - The p-value is commonly set at 0.05 as a cut-off point. Accept the hypothesis if your Χ
^{2}value is smaller than the Χ^{2}value for p=0.05 in the table, and reject the hypothesis if your Χ^{2}value is larger than the Χ^{2}value for p=0.05 in the table.

## Chi-squared table

°'s of Freedom | Probability | ||||

.9 | .5 | .1 | .05 | .01 | |

1 | 0.02 | 0.46 | 2.71 | 3.84 | 6.64 |

2 | 0.21 | 1.39 | 4.61 | 5.99 | 9.21 |

3 | 0.58 | 2.37 | 6.25 | 7.82 | 11.35 |

4 | 1.06 | 3.36 | 7.78 | 9.49 | 13.28 |

5 | 1.61 | 4.35 | 9.24 | 11.07 | 15.09 |

## Example Chi-squared (Χ^{2}) tests

We hypothesize that a certain fruit fly that we believe is a dihybrid heterozygote of genotype AaBb (A are B independently segregate). To test this hypothesis, we cross this fly to a fly that we know is AaBb and expect a 9:3:3:1 ratio of A-B-, A-bb, aaB-, and aabb in the progeny.

Here are expected results of a **AbBb x AaBb** cross:

9 | A_B_ | (red eyes; straight wings) |

3 | A_bb | (red eyes; curly wings) |

3 | aaB_ | (white eyes; straight wings) |

1 | aabb | (white eyes; curly wings) |

However, even if the hypothesis is true, in real life we often do not get a exact 9:3:3:1 ratio. We might instead get the following observed data:

Here are observed results of a **AbBb x AaBb** cross:

921 | A_B_ | (red eyes; straight wings) |

310 | A_bb | (red eyes; curly wings) |

274 | aaB_ | (white eyes; straight wings) |

95 | aabb | (white eyes; curly wings) |

Total = 1600 |

What the Χ^{2} test tells you is whether these observed results are close enough to the expected results (9:3:3:1), and from that, we can either accept or reject our hypothesis that this fly we obtained is indeed a dihybrid heterozygote.

To calculate the Χ^{2} value, it is most clear if you make a table.

A-B- | A-bb | AaB- | aabb | |
---|---|---|---|---|

observed | 921 | 310 | 274 | 95 |

expected | 900 = (9/16 of 1600) | 300 = (3/16 of 1600) | 300 = (3/16 of 1600) | 100 = (1/16 of 1600) |

observed - expected | 21 | 10 | -26 | -5 |

(observed-expected)^{2} | 441 | 100 | 676 | 25 |

(observed-expected)^{2} / expected | 0.490 = (441/900) | 0.333 = (100/300) | 2.245 = (676/300) | 0.25 = (25/100) |

Sum Χ^{2} = 3.3.26 |

Degree of freedom is the number of events (or categories) minuses one (4 categories in this example '9, 3, 3, & 1, so the degree of freedom is 3).

Question. Do you accept or reject the hypothesis (the fly has AaBb genotype) in the above example?