34 Tests for a proportion
$$
$$
We now consider testing hypotheses about an unknown proportion \(p\) based on a random sample \(X_1,\dots,X_n\) of Bernoulli\((p)\) random variables. Specifically, given a null value \(p_0\), we will consider testing sets of hypotheses in these forms:
- \(H_0\): \(p \leq p_0\) versus \(H_1\): \(p > p_0\).
- \(H_0\): \(p \geq p_0\) versus \(H_1\): \(p < p_0\).
- \(H_0\): \(p = p_0\) versus \(H_1\): \(p \neq p_0\).
To test any of these hypotheses, we will consider how far away the sample proportion \(\hat p_n\) is from \(p_0\) in the direction specified by the alternate hypothesis. We will reject \(H_0\) if \(\hat p_n\) is far enough away from the null value \(p_0\) in that direction. In order to determine how far is far enough, we will use the fact that if the true population proportion \(p\) is equal to \(p_0\), then we will have \[ \frac{\hat p_n - p_0}{\sqrt{p_0(1-p_0)/n}} \overset{\operatorname{approx}}{\sim}\mathcal{N}(0,1) \] for large enough \(n\), owing to the Central Limit Theorem as interpreted for the sample proportion in Proposition 21.2.
We will therefore define as our test statistic the quantity \[ Z_{\operatorname{test}}= \frac{\hat p_n - p_0}{\sqrt{p_0(1-p_0)/n}}, \tag{34.1}\] which can be interpreted as the number of standard deviations \(\hat p_n\) lies away from \(p\), signed such that it is negative with \(\hat p_n < p_0\) and positive when \(\hat p_n > p_0\). The Central Limit Theorem allows us to define rejection rules as summarized here:
Proposition 34.1 (Large-sample test for a proportion) Let \(X_1,\dots,X_n \overset{\text{ind}}{\sim}\text{Bernoulli}(p)\). Then the following tests have size closer and closer to \(\alpha\) for larger and larger \(n\):
- For \(H_0\): \(p \leq p_0\) versus \(H_1\): \(p > p_0\), reject \(H_0\) if \(Z_{\operatorname{test}}> z_\alpha\).
- For \(H_0\): \(p \geq p_0\) versus \(H_1\): \(p < p_0\), reject \(H_0\) if \(Z_{\operatorname{test}}< -z_\alpha\).
- For \(H_0\): \(p = p_0\) versus \(H_1\): \(p \neq p_0\), reject \(H_0\) if \(|Z_{\operatorname{test}}| > z_{\alpha/2}\).
Note that for the above tests to be reliable in the sense of having truly the advertised size (recall that the size is the maximum probability that the test will lead to a Type I error) the sample size must be “large”. In the particular case of testing for a proportion, we find it is not sufficient to require merely \(n \geq 30\), since, as it turns out, the convergence in the behavior of \(Z_{\operatorname{test}}\) in Equation 34.1 to that of a standard normal random variable may be slower or faster depending on the value of the true proportion \(p\). If \(p\) is quite close to zero or one, a larger sample size \(n\) is needed for \(Z_{\operatorname{test}}\) to behave approximately like a standard normal random variable. The rule of thumb \[ \min\{np_0,n(1-p_0)\} \geq 15 \] is generally proposed. This rule requires that the expected number of successes and the expected number of failures, based on the sample size \(n\) and the null value \(p_0\), should both be at least \(15\).
Exercise 34.1 (Parasite in flies) A scientist is interested in seeing whether the presence of a parasite tips the sex ratio of the hosts’ offspring in favor of females (which would be advantageous to the parasite, as it inhabits only females). A sample of size \(n=500\) offspring from parasite-infected females is collected, among which \(287\) females are identified.
We conclude this page by remarking that there are other ways to test hypotheses about a proportion. One can use the fact that \(Y = X_1+\dots+X_n\) follows the \(\text{Binomial}(n,p_0)\) distribution if \(p = p_0\), and from here define a rejection rule in terms of \(Y\) which will guarantee that the Type I error rate will not exceed a desired size \(\alpha\). One drawback of this approach is that, since \(Y\) is a discrete random variable, it may not be possible, depending on the sample size and the desired maximum Type I error rate \(\alpha\), to define a test based on \(Y\) which has size exactly equal to the desired \(\alpha\).
Assuming that the proportion of females in the offspring of the host species is \(1/2\) in the absence of the parasite, the hypotheses of interest are \(H_0\): \(p \leq 1/2\) versus \(H_1\): \(p > 1/2\), where \(p\) is the proportion of females in the offspring of parasite-infected hosts.↩︎
We first compute the test statistic \[ Z_{\operatorname{test}}= \frac{287/500 - 1/2}{\sqrt{1/2(1-1/2)/500}} = 3.309. \] The critical value is \(z_{0.05}=1.645\). Since \(3.309 > 1.645\), the test statistic lies in the rejection region, so we reject \(H_0\) and conclude that the parasite indeed tips the sex ratio of offspring in favor of females.↩︎