An R Introduction to Statistics

Upper Tail Test of Population Proportion

The null hypothesis of the upper tail test about population proportion can be expressed as follows:

p ≤ p0

where p0 is a hypothesized upper bound of the true population proportion p.

Let us define the test statistic z in terms of the sample proportion and the sample size:

        ¯p− p0
z = ∘------------
      p0(1− p0)∕n

Then the null hypothesis of the upper tail test is to be rejected if z zα , where zα is the 100(1 α) percentile of the standard normal distribution.

Problem

Suppose that 12% of apples harvested in an orchard last year was rotten. 30 out of 214 apples in a harvest sample this year turns out to be rotten. At .05 significance level, can we reject the null hypothesis that the proportion of rotten apples in harvest stays below 12% this year?

Solution

The null hypothesis is that p 0.12. We begin with computing the test statistic.

> pbar = 30/214          # sample proportion 
> p0 = .12               # hypothesized value 
> n = 214                # sample size 
> z = (pbarp0)/sqrt(p0(1p0)/n) 
> z                      # test statistic 
[1] 0.90875

We then compute the critical value at .05 significance level.

> alpha = .05 
> z.alpha = qnorm(1alpha) 
> z.alpha                # critical value 
[1] 1.6449

Answer

The test statistic 0.90875 is not greater than the critical value of 1.6449. Hence, at .05 significance level, we do not reject the null hypothesis that the proportion of rotten apples in harvest stays below 12% this year.

Alternative Solution 1

Instead of using the critical value, we apply the pnorm function to compute the upper tail p-value of the test statistic. As it turns out to be greater than the .05 significance level, we do not reject the null hypothesis that p 0.12.

> pval = pnorm(z, lower.tail=FALSE) 
> pval                   # upper tail pvalue 
[1] 0.18174

Alternative Solution 2

We apply the prop.test function to compute the p-value directly. The Yates continuity correction is disabled for pedagogical reasons.

> prop.test(30, 214, p=.12, alt="greater", correct=FALSE) 
 
        1sample proportions test without continuity 
        correction 
 
data:  30 out of 214, null probability 0.12 
Xsquared = 0.8258, df = 1, pvalue = 0.1817 
alternative hypothesis: true p is greater than 0.12 
95 percent confidence interval: 
 0.10563 1.00000 
sample estimates: 
      p 
0.14019