# Calculating Chi-Squared

## $2 \times 2$ Contingency Table

The following shows the results of a survey of a sample of $200$ randomly chosen adults classified according to gender and sport. These are called observed values or observed frequencies.
$$\begin{array}{|c|c|c|c|} \hline & \text{loves sport} & \text{hates sport} & \text{sum} \\ \hline \text{male} & 72 & 48 & 120 \\ \hline \text{female} & 18 & 62 & 80 \\ \hline \text{sum} & 90 & 110 & 200 \\ \hline \end{array}$$

## Expected Frequency Table

$$\begin{array}{|c|c|c|c|} \hline & \text{loves sport} & \text{hates sport} & \text{sum} \\ \hline \text{male} & \dfrac{120 \times 90}{200} = 54 & \dfrac{120 \times 110}{200} = 66 & 120 \\ \hline \text{female} & \dfrac{80 \times 90}{200} = 36 & \dfrac{80 \times 110}{200} = 44 & 80 \\ \hline \text{sum} & 90 & 110 & 200 \\ \hline \end{array}$$

## Calculating $\chi^{2}$

$$\chi^{2} = \sum \dfrac{(f_o – f_e)^2}{f_e}$$

$f_o$ is an observed frequency
$f_e$ is an expected frequency

$$\begin{array}{|c|c|r|c|c|} \hline f_o & f_e & f_o – f_e & (f_o – f_e)^2 & \dfrac{(f_o – f_e)^2}{f_e} \\ \hline 72 & 54 & 18 & 324 & 6.0 \\ \hline 48 & 66 & -18 & 324 & 4.9 \\ \hline 18 & 36 & -18 & 324 & 9.0 \\ \hline 62 & 44 & 18 & 324 & 7.4 \\ \hline &&& \text{sum} & 27.3 \\ \hline \end{array} \\ \therefore \chi^2 = 27.3$$

## $2 \times 3$ Contingency Table

The following shows the results of a survey of a sample of $500$ randomly chosen adults classified according to gender and political preferences. These are called observed values or observed frequencies.
$$\begin{array}{|c|c|c|c|c|} \hline & \text{Liberal} & \text{neutral} & \text{Democrates} & \text{sum} \\ \hline \text{male} & 120 & 40 & 90 & 260 \\ \hline \text{female} & 105 & 50 & 95 & 240 \\ \hline \text{sum} & 225 & 90 & 185 & 500 \\ \hline \end{array}$$

## Expected Frequency Table

$$\begin{array}{|r|r|r|r|r|} \hline & \text{Liberal} & \text{neutral} & \text{Democrats} & \text{sum} \\ \hline \text{male} & \dfrac{260 \times 225}{500} = 117 & \dfrac{260 \times 90}{500} = 46.8 & \dfrac{260 \times 185}{500} = 96.2 & 260 \\ \hline \text{female} & \dfrac{240 \times 225}{500} = 108 & \dfrac{240 \times 90}{500} = 43.2 & \dfrac{240 \times 185}{500} = 88.8 & 240 \\ \hline \text{sum} & 225 & 90 & 185 & 500 \\ \hline \end{array}$$

## Calculating $\chi^{2}$

$$\chi^{2} = \sum \dfrac{(f_o – f_e)^2}{f_e}$$

$f_o$ is an observed frequency
$f_e$ is an expected frequency

$$\begin{array}{|r|r|r|r|r|} \hline f_o & f_e & f_o – f_e & (f_o – f_e)^2 & \dfrac{(f_o – f_e)^2}{f_e} \\ \hline 120 & 117.0 & 3.0 & 9.00 & 0.0769 \\ \hline 40 & 46.8 & -6.8 & 46.24 & 0.9880 \\ \hline 100 & 96.2 & 3.8 & 14.44 & 0.1501 \\ \hline 105 & 108.0 & -3.0 & 9.00 & 0.0833 \\ \hline 50 & 43.2 & 6.8 & 46.24 & 1.0704 \\ \hline 85 & 88.8 & -3.8 & 14.44 & 0.1626 \\ \hline &&& \text{sum} & 2.5314 \\ \hline \end{array} \\ \therefore \chi^2 = 2.5314$$