Two-Tailed Test of Population Proportion
The null hypothesis of the two-tailed test about population proportion can be expressed as follows:
where p0 is a hypothesized value of the true population proportion p.
Let us define the test statistic z in terms of the sample proportion and the sample size:
Suppose a coin toss turns up 12 heads out of 20 trials. At .05 significance level, can one reject the null hypothesis that the coin toss is fair?
The null hypothesis is that p = 0.5. We begin with computing the test statistic.
> p0 = .5 # hypothesized value
> n = 20 # sample size
> z = (pbar−p0)/sqrt(p0∗(1−p0)/n)
> z # test statistic
We then compute the critical values at .05 significance level.
The test statistic 0.89443 lies between the critical values -1.9600 and 1.9600. Hence, at .05 significance level, we do not reject the null hypothesis that the coin toss is fair.
Instead of using the critical value, we apply the pnorm function to compute the two-tailed p-value of the test statistic. It doubles the upper tail p-value as the sample proportion is greater than the hypothesized value. Since it turns out to be greater than the .05 significance level, we do not reject the null hypothesis that p = 0.5.
We apply the prop.test function to compute the p-value directly. The Yates continuity correction is disabled for pedagogical reasons.
1−sample proportions test without continuity
data: 12 out of 20, null probability 0.5
X−squared = 0.8, df = 1, p−value = 0.3711
alternative hypothesis: true p is not equal to 0.5
95 percent confidence interval: