S3.4 - Goodness of fit and contingency tables

Syllabus
2019
Topic
S3.4
Level
A2

Learning objectives

Use a chi-squared test for fit or association

A chi-squared test compares observed frequencies OiO_i with frequencies EiE_i expected under a null model. Large discrepancies produce a large statistic and evidence against H0H_0; the alternative says the stated model or independence claim does not hold.

For goodness of fit, write H0H_0: the named distribution is a suitable model, and H1H_1: it is not suitable. Required models include discrete uniform, binomial, Normal, Poisson and continuous uniform (rectangular). For a contingency table, write H0H_0: the two named variables are independent (no association), and H1H_1: they are associated.

\chi^2=\sum_i\frac{(O_i-E_i)^2}{E_i}

For goodness of fit, calculate Ei=NpiE_i=Np_i from the null distribution. For an r×cr\times c contingency table, Eij=(row total)(column total)/NE_{ij}=(\text{row total})(\text{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)O=(8,12,9,11,10) and E=(10,10,10,10,10)E=(10,10,10,10,10). Then χ2=(4+4+1+1+0)/10=1.0\chi^2=(4+4+1+1+0)/10=1.0. With 4 degrees of freedom, 1.0<9.4881.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 H0H_0. Use frequencies, not raw measurements or percentages, and do not describe association as correlation.

Choose chi-squared degrees of freedom correctly

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 kk is the final number of cells and pp is the number of distribution parameters estimated from the sample. If every parameter is specified in advance, p=0p=0. For example, six final Poisson cells with the mean estimated from the data give ν=611=4\nu=6-1-1=4. If combining reduces the table to five cells, use ν=3\nu=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<5E_i<5, combine suitable neighbouring or tail categories before calculating the final statistic; recompute each combined OO and EE, and base kk and the degrees of freedom on the combined table.

A 3×43\times4 contingency table has ν=(31)(41)=6\nu=(3-1)(4-1)=6. Its expected frequencies still come from row total ×\times column total /N/N; the observed counts do not determine ν\nu.

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.