8 Confidence Intervals for One Parameter

8.2 Confidence Intervals for Proportions

Goal:
Learn how to calculate confidence intervals for population proportion p.

Recall that the sampling distribution for proportions becomes approximately normally distributed with μ=p and σ=p(1-p)n given np10 and n(1-p)10. With this in mind, we can then construct a 1-α confidence interval for proportions.

Theorem (Confidence Interval for p).

Assuming a random sample is taken with a sample proportion of p^, along with np^10 and n(1-p^)10, then the 1-α confidence interval for p is given by

(p^-z*p^(1-p^)n,p^+z*p^(1-p^)n),

where z* is the critical value from the standard normal distribution such that P(Zz*)=α/2.

For review on calculating z*, visit the previous section on finding a 1-α confidence interval for μ, knowing σ. We will assume here that you have a sufficient understanding of calculating z*.

Figure 8.5 has the commands needed to compute a 1-α confidence interval for p. The table below summarizes them again.

Action Excel Commands Python Commands
Compute the Square Root 𝚂𝚀𝚁𝚃() sqrt(…)
Compute z* 𝙽𝙾𝚁𝙼𝙸𝙽𝚅(𝟷-0.5*α,𝟶,𝟷) norm.ppf(1-0.5*α)
  • The mean and sqrt commands require the library numpy . The norm.ppf command requires the library scipy.stats .

Figure 8.20: Commands Needed to Construct Confidence Interval for p

Let’s see an example in Excel and Python.

Example 8.2.1.

Given n=200, p^=0.2, and 1-α=95%, compute a confidence interval for p in Excel.

Before we progress, we need to check the normality conditions: np^=200(0.2)=4010 and n(1-p^)=200(0.8)=16010. Since they hold true, we can proceed.

On a new sheet in Excel, in cell 𝙰𝟷, type the string 𝚉*.

In cell 𝙱𝟷, type the following command to compute z*, the critical value associated with α=0.05.

=𝙽𝙾𝚁𝙼𝙸𝙽𝚅(𝟷-0.5*0.05,𝟶,𝟷)

In cells 𝙳𝟷 and 𝙴𝟷, type the strings 𝙻𝙾𝚆𝙴𝚁 and 𝚄𝙿𝙿𝙴𝚁.

Recall that the confidence interval for p is

(p^-z*p^(1-p^)n,p^+z*p^(1-p^)n).

With this in mind, in cell 𝙳𝟸 compute the lower value of the confidence interval by typing the command

=0.2-𝙱𝟷*𝚂𝚀𝚁𝚃(0.2*(𝟷-0.2)/𝟸𝟶𝟶)

Similarly, in cell 𝙴𝟸 compute the upper value of the confidence interval by typing the command

=0.2+𝙱𝟷*𝚂𝚀𝚁𝚃(0.2*(𝟷-0.2)/𝟸𝟶𝟶)
Figure 8.21: Confidence Interval for p in Excel

You should obtain (0.144563847, 0.255436153) for the 95% confidence interval for p.

Example 8.2.2.

Given n=1236, p^=0.088, and 1-α=99%, compute a confidence interval for p in Python.

Before we progress, we need to check the normality conditions: np^=1236(0.088)=108.76810 and n(1-p^)=1236(0.912)=1127.23210. Since they hold true, we can proceed.

Remember to load numpy and scipy.stats since we are using Python. To do so, type:

from numpy import *
from scipy.stats import *

Let’s compute z* and store it to the variable zstar by typing the command

zstar = norm.ppf(1-0.05*0.01)

Note that α=0.01.

Let’s name the lower value of the confidence interval as LOWER. At the prompt, type the following to assign it to LOWER.

LOWER = 0.088 - zstar*sqrt(0.088*(1-0.088)/1236)

Repeat the same process for the upper value of the confidence interval by typing the following command and storing it as UPPER.

UPPER = 0.088 + zstar*sqrt(0.088*(1-0.088)/1236)

Let’s have Python print out the confidence interval. Type the following.

print "(%f, %f)" %(LOWER, UPPER)

You should obtain the confidence interval (0.067244, 0.108756). Figure 8.22 represents the layout you should obtain in Python when finished.

Figure 8.22: Confidence Interval for p In Python

Concepts Check: 1. Check the normality conditions if n=100 and p^=0.48. Can we assume the sample distribution for p is normally distributed? Answer: np^=4810, n(1-p^)=5210. You can assume normality. 2. Compute the 92% confidence interval for p given n=100, p^=0.48. Answer: (0.418153437, 0.541846563)

8.2.1 Exercises

  1. 1.

    Answer each of the following statements as True or False.

    1. (a)

      p^ stands for population proportion.

    2. (b)

      The 1-α confidence interval for p attempts to estimate the location of the sample proportion.

    3. (c)

      The Student’s t-distribution is used when constructing a 1-α confidence interval for p.

    4. (d)

      The command in Python to compute z* is norminv(1-0.5*α,0,1).

    5. (e)

      A 1-α confidence interval for p will always capture p.

  2. 2.

    Assuming normality condition is satisfied and given n, p^, and α, compute the 1-α confidence intervals for p in Excel.

    1. (a)

      n=20, p^=0.05, α=0.12.

    2. (b)

      n=250, p^=0.43, α=0.04.

    3. (c)

      n=1002, p^=0.23, α=0.08.

  3. 3.

    Assuming normality condition is satisfied and given n, p^, and α, compute the 1-α confidence interval for p in Python.

    1. (a)

      n=20, p^=0.05, α=0.2.

    2. (b)

      n=250, p^=0.43, α=0.1.

    3. (c)

      n=1002, p^=0.23, α=0.05.

  4. 4.

    In a random sample of 64 people in a city, 37.5% were in favor of lowering the drunk driving blood alcohol level from 0.1 to 0.08. Fin a 90% confidence interval for the population proportion in favor of lowering the drunk driving blood alcohol level from 0.1 to 0.08. Interpret the confidence interval in the language of the problem.

  5. 5.

    Given the data set Bostrain.xlsx, construct a 95% confidence interval estimate of the proportion of Wednesdays with precipitation. Assume that values diffferent from 0 to be days with precipitation. Interpret the confidence interval in the language of the data.

  6. 6.

    Assume that a coin is modified so that it favors head and 100 tosses results in 90 heads. Find the 99.99% confidence interval estimate of the proportion of heads that will occur with this coin. What is unusual about this confidence interval? How can it be modified?

  7. 7.

    Create an Excel worksheet that allows you to enter p^, n, and α and will outright compute the 1-α confidence interval for p. This should be user-friendly with labels on the three inputs.

  8. 8.

    Create a Python script that allows you to enter p^, n, and α and it outputs the 1-α confidence interval for p, printed nicely.