Chi-square test

For count data: do the observed counts fit the expected ratios, and are two traits related?

Test type

Question: Do the observed counts fit the ratios the theory expects?
Example: Mendel’s pea experiment: counts of round-yellow, round-green, wrinkled-yellow and wrinkled-green seeds. Inheritance theory predicts a 9:3:3:1 ratio. Do the data fit?

ClassObserved (O)Expected ratioExpected (E)Delete
312.75
104.25
104.25
34.75
H0:The observed counts fit the expected ratiosH_0: \text{The observed counts fit the expected ratios}H1:They do not fitH_1: \text{They do not fit}
02.557.51012.5157.815calculated 0.47χ² (df = 3)

The red area is the rejection region (α = 0.05). The green line is the value calculated from your data.

H₀ not rejected: the difference is not significant

The gap between observed and expected counts can be explained by chance; the data fit the ratios.

p-value = 0.9254

How was it calculated?

χcalc2\chi^2_{calc} = 0.47

  1. Expected frequencies: the total count (556) is shared out according to the ratios.

    Ei=n⋅ratioi∑ratio⇒312.75, 104.25, 104.25, 34.75E_i = n \cdot \dfrac{\text{ratio}_i}{\sum \text{ratio}} \Rightarrow 312.75,\ 104.25,\ 104.25,\ 34.75
  2. In each class, square the gap between observed and expected, divide by expected and add up.

    χ2=∑(O−E)2E=(315−312.75)2312.75+(108−104.25)2104.25+(101−104.25)2104.25+(32−34.75)234.75\chi^2 = \sum \dfrac{(O - E)^2}{E} = \dfrac{(315 - 312.75)^2}{312.75} + \dfrac{(108 - 104.25)^2}{104.25} + \dfrac{(101 - 104.25)^2}{104.25} + \dfrac{(32 - 34.75)^2}{34.75}
  3. χ2=0.016+0.135+0.101+0.218=0.47\chi^2 = 0.016 + 0.135 + 0.101 + 0.218 = 0.47
  4. Degrees of freedom = number of classes − 1 = 3. The chi-square test is always right-tailed: only large deviations indicate a poor fit.

  5. Compare the calculated value with the table (critical) value.

    χcalc2=0.47≤χtab2=7.815\chi^2_{calc} = 0.47 \le \chi^2_{tab} = 7.815
  6. The calculated value is in the acceptance region: H₀ cannot be rejected. The p-value (0.9254) is not smaller than α = 0.05.