[Math] An Example dealing with the Chi-Square Test

probabilityprobability distributionsstatistics

Problem:
In $60$ tosses of a coin, $37$ heads and $23$ tails were observed. Test the
hypothesis that the coin is fair, using a significant level of (a) $0.05$, (b)
$0.01$.
Answer:
\begin{eqnarray*}
df &=& 2 – 1 = 1 \\
\chi^2 &=& \frac{(37-30)^2}{30} + \frac{(30-23)^2}{30} \\
\chi^2 &=& \frac{49}{30} + \frac{49}{30} = \frac{49}{15} \\
\chi^2 &=& 3.26667 \\
\end{eqnarray*}
Using software I find that $P(\chi^2 < 3.26667) = 0.93$. Therefore, I reject the idea the coin is fair at both the $0.05$ and $0.01$ levels.

The book's answer is:
The hypothesis cannot be rejected at either level.

What did I do wrong?
Bob

Best Answer

With a $\chi^2$ test we reject if our test statistic is greater than the critical value.

Let $$H_0: p=0.5$$

$$H_a: p\neq0.5$$

We have $$\chi^2=\sum \frac{(O-E)^2}{E}$$

where $E=30$ for both groups so

$$\begin{align*} \chi^2 &=\sum \frac{(O-E)^2}{E}\\\\ &=\frac{(37-30)^2}{30}+\frac{(23-30)^2}{30}\\\\ &\approx3.27 \end{align*}$$

We look at a $\chi^2$ table at $\alpha=0.05$ with $df=1$ and get a critical value of $3.84$. Thus we fail to reject the null hypothesis since $3.27\lt 3.84$.

We look at a $\chi^2$ table at $\alpha=0.01$ with $df=1$ and get a critical value of $6.635$. Thus we fail to reject the null hypothesis since $3.27\lt 6.635$.

Using software you should find

1 - pchisq(3.27, 1)
[1] 0.07055762

so we fail to reject at either significance level since $0.706\gt0.05\gt0.01$

Another Test:

Using a binomial test, the probability of getting $23$ or less heads or $23$ or less tails when flipping a fair coin $60$ times is

$$2\cdot\sum_{k=0}^{23} {60 \choose k}0.5^{60}\approx0.0925$$

> sum(dbinom(0:23,60,.5))*2
[1] 0.09246098

so using this test, we fail to reject at both significance levels as well.