Salick Academy

Chi-Squared Goodness of Fit

No calculator

Unit 1 used χ2\chi^2 to ask whether two variables in a table are independent. Here the question is different: does a single set of frequencies fit a proposed distribution? The arithmetic is identical; what changes is how the expected frequencies are produced and how the degrees of freedom are counted.

The goodness-of-fit idea

χ2=(OE)2E\chi^2 = \sum \frac{(O - E)^2}{E}

  • H0H_0: the data follow the stated distribution
  • H1H_1: the data do not follow it

A large χ2\chi^2 means observed and expected are far apart, so the model is rejected. The test is always one-tailed on the right — only large values count as evidence against the fit.

Equal proportions

The simplest model: every category equally likely.

A die is rolled 120 times.

Face 1 2 3 4 5 6 Total
OO 15 23 18 22 17 25 120
EE 20 20 20 20 20 20 120

χ2=25+9+4+4+9+2520=7620=3.80\chi^2 = \frac{25 + 9 + 4 + 4 + 9 + 25}{20} = \frac{76}{20} = 3.80

Degrees of freedom: ν=61=5\nu = 6 - 1 = 5, since the six expected frequencies are free apart from having to total 120. The 5% critical value is χ0.05,52=11.070\chi^2_{0.05,5} = 11.070.

As 3.80<11.0703.80 < 11.070, do not reject H0H_0: there is no evidence at the 5% level that the die is biased.

A stated ratio

A genetic theory predicts four phenotypes in the ratio 9:3:3:19:3:3:1. Of 320 plants:

Phenotype A B C D Total
OO 168 64 68 20 320
EE 180 60 60 20 320

The expected values come from splitting 320 in the ratio: 916(320)=180\tfrac{9}{16}(320) = 180, 316(320)=60\tfrac{3}{16}(320) = 60, and so on.

χ2=144180+1660+6460+0=0.800+0.267+1.067=2.13\chi^2 = \frac{144}{180} + \frac{16}{60} + \frac{64}{60} + 0 = 0.800 + 0.267 + 1.067 = 2.13

With ν=41=3\nu = 4 - 1 = 3 and χ0.05,32=7.815\chi^2_{0.05,3} = 7.815, the theory is not rejected.

Fitting a Poisson distribution

Now the model has a parameter, and the parameter is estimated from the data.

Accidents per week at a factory, over 100 weeks:

Accidents 0 1 2 3 4\ge 4 Total
Weeks 26 28 24 14 8 100

The total number of accidents is 0(26)+1(28)+2(24)+3(14)+4(8)=1500(26) + 1(28) + 2(24) + 3(14) + 4(8) = 150, so

λ^=150100=1.5\hat\lambda = \frac{150}{100} = 1.5

Expected frequencies are 100×P(X=x)100 \times P(X = x) for Po(1.5)\text{Po}(1.5), with the last class taking whatever is left:

xx 0 1 2 3 4\ge 4
P(X=x)P(X=x) 0.2231 0.3347 0.2510 0.1255 0.0656
EE 22.31 33.47 25.10 12.55 6.56

χ2=3.69222.31+5.47233.47+1.10225.10+1.45212.55+1.4426.56=2.03\chi^2 = \frac{3.69^2}{22.31} + \frac{5.47^2}{33.47} + \frac{1.10^2}{25.10} + \frac{1.45^2}{12.55} + \frac{1.44^2}{6.56} = 2.03

Degrees of freedom

ν=(number of classes)1(parameters estimated from the data)\nu = (\text{number of classes}) - 1 - (\text{parameters estimated from the data})

  • Equal proportions or a stated ratio: nothing is estimated, so ν=k1\nu = k - 1.
  • Poisson with λ\lambda estimated: ν=k2\nu = k - 2.
  • Binomial with pp estimated: ν=k2\nu = k - 2. If pp is stated in the question, nothing is estimated and ν=k1\nu = k - 1.
  • Normal with both μ\mu and σ\sigma estimated: ν=k3\nu = k - 3.

For the accident data, ν=511=3\nu = 5 - 1 - 1 = 3 and χ0.05,32=7.815\chi^2_{0.05,3} = 7.815. Since 2.03<7.8152.03 < 7.815, the Poisson model is not rejected — accidents are consistent with occurring at random at a constant rate.

Pooling small classes

The test requires every expected frequency to be at least 5. Where one is smaller, combine adjacent classes until it is not.

Suppose the tail gave E=3.1E = 3.1 and 1.21.2. Merging them into a single class with E=4.3E = 4.3 is still below 5, so merge one class further in. Then recount:

ν=(classes AFTER pooling)1(parameters estimated)\nu = (\text{classes AFTER pooling}) - 1 - (\text{parameters estimated})

Writing the conclusion

A complete answer has five parts:

  1. H0H_0 and H1H_1 stated in context
  2. EE computed, with E=O\sum E = \sum O checked
  3. χ2=(OE)2E\chi^2 = \sum \dfrac{(O-E)^2}{E}
  4. ν\nu, with the parameter count justified, and the critical value quoted
  5. A comparison and a sentence in the language of the question