S3.4 - Goodness of fit and contingency tables
- Syllabus
- 2019
- Topic
- S3.4
- Level
- A2
A chi-squared test compares observed frequencies Oi with frequencies Ei expected under a null model. Large discrepancies produce a large statistic and evidence against H0; the alternative says the stated model or independence claim does not hold.
For goodness of fit, write H0: the named distribution is a suitable model, and H1: it is not suitable. Required models include discrete uniform, binomial, Normal, Poisson and continuous uniform (rectangular). For a contingency table, write H0: the two named variables are independent (no association), and H1: they are associated.
\chi^2=\sum_i\frac{(O_i-E_i)^2}{E_i}
For goodness of fit, calculate Ei=Npi from the null distribution. For an r×c contingency table, Eij=(row total)(column total)/N. Compare the statistic with the upper-tail critical value for the chosen significance level and degrees of freedom.
For 50 observations in five equally likely categories, suppose O=(8,12,9,11,10) and E=(10,10,10,10,10). Then χ2=(4+4+1+1+0)/10=1.0. With 4 degrees of freedom, 1.0<9.488 at 5%, so do not reject the discrete-uniform model.
A small statistic does not prove the model or independence; it means the data do not provide sufficient evidence against H0. Use frequencies, not raw measurements or percentages, and do not describe association as correlation.
Degrees of freedom select the correct chi-squared reference distribution. Count categories after any required combining, then subtract constraints created by the total frequency and by parameters estimated from the same data.
\nu=k-1-p\quad\text{for goodness of fit}
Here k is the final number of cells and p is the number of distribution parameters estimated from the sample. If every parameter is specified in advance, p=0. For example, six final Poisson cells with the mean estimated from the data give ν=6−1−1=4. If combining reduces the table to five cells, use ν=3.
\nu=(r-1)(c-1)\quad\text{for an }r\times c\text{ contingency table}
The chi-squared approximation requires adequate expected frequencies. When Ei<5, combine suitable neighbouring or tail categories before calculating the final statistic; recompute each combined O and E, and base k and the degrees of freedom on the combined table.
A 3×4 contingency table has ν=(3−1)(4−1)=6. Its expected frequencies still come from row total × column total /N; the observed counts do not determine ν.
Subtract only parameters estimated from these data, not parameters supplied by the null model. Do not use the original number of cells after combining, and do not apply Yates' correction; it is not required in this specification.