Chi-square goodness-of-fit test

Database › Mathematics › Applied mathematics › Statistics

STAT-0004MethodUndergraduate

The chi-square statistic sums squared deviations of data from a model in units of their expected spread; compared with its distribution for the right number of degrees of freedom it tests goodness of fit.

$$\chi^2=\sum_{k=1}^K\frac{(O_k-E_k)^2}{E_k},\qquad\chi^2=\sum_i\frac{(y_i-f(x_i))^2}{\sigma_i^2},\qquad\nu=K-1-m,\quad E[\chi^2]=\nu,\ \ V[\chi^2]=2\nu$$

Explanation

If each term is the square of an approximately standard Gaussian deviation, $\chi^2$ follows the chi-square distribution with $\nu$ degrees of freedom: the number of terms minus the constraints (a fixed total) and fitted parameters $m$. For binned counts the variance is $E_k$ (Poisson), so bins should hold at least about five expected counts.

A value near $\nu$ (reduced $\chi^2/\nu\approx1$) is consistent; a very large value rejects the model, and a very small one suggests overestimated errors. The $p$-value is the tail probability above the observed $\chi^2$.

Example 1

A die thrown 60 times gives faces 1–6 with frequencies 8, 12, 9, 11, 6, 14. Is it consistent with a fair die at the 5% level ($\chi^2_{0.05}(5)=11.07$)?

Solution

$E_k=10$: $\chi^2=\frac{4+4+1+1+16+16}{10}=4.2$ with $\nu=5$; $4.2<11.07$, so fairness is not rejected.

Example 2

A straight line fitted to 12 data points gives $\chi^2=31$. Comment.

Solution

$\nu=12-2=10$, expected $10\pm\sqrt{20}\approx10\pm4.5$; 31 is far above, so either the model is wrong (curvature) or the errors are underestimated.

Related entries