Interactive demo · Introduction to Mathematical Statistics · Chapter 10

Why Pearson's statistic has t − 1 degrees of freedom

Put n observations into t classes with probabilities p1, …, pt and form the Pearson residuals Ui = (Xi − npi)/√(npi). Pearson's statistic is their sum of squares, D = ΣUi2, the squared length of the vector U. Because the counts add up to n, that vector is always perpendicular to u = (√p1, …, √pt): it lives in a (t − 1)-dimensional subspace, where for large n it behaves like t − 1 independent standard normal coordinates. Its squared length is then χ2 with t − 1 degrees of freedom. The top panel shows the residual vectors in coordinates W1, W2 of that subspace; the middle panel the eigenvalues of their covariance (t − 1 ones and a zero); the bottom panel the distribution of D.

Hypothesised model

Sample size n

Simulated samples

Try these

Each simulated sample puts n observations into the classes independently with the probabilities of the model (a multinomial vector, Theorem 10.2.1). W1, W2 are the first two coordinates of U in an orthonormal basis of the subspace perpendicular to u (Gram–Schmidt applied to u, e1, e2, …). With t = 3 classes D = W12 + W22 exactly, so the 0.05 test rejects exactly the points outside the red circle of radius √5.991. The exact size adds the multinomial probabilities of every outcome with D ≥ χ20.95, t−1; it is computed when there are at most two million outcomes. The exact variance of D is 2(t − 1) + (Σ1/pi − t2 − 2t + 2)/n. Random numbers are seeded, so a preset always shows the same draws.

In the lecture notes