Last week, we talked about confidence intervals for means coming from numerical data. Today, we'll do something quite similarfor proportions that arise from categorical data.

Like, last Wednesday's presentation, this is related to sections 5.1 and 5.2 of our text but follows that even more closely.

Suppose we take a random sample of 100 North Carolinians and check whether they are left handed or right handed. If 13 of them are left handed, we would say that the proportion of them who are left handed is $13\%$. That $13\%$ is a *sample proportion* $\hat{p}$ that estimates the *population proportion* $p$.

Note that a proportion is a numerical quantity, even though the data is categorical. Thus, we can compute confidence intervals in a very similar way. Just as with sample means, the sampling process leads to a random variable and, if certain assumptions are met, then we can expect that random variable to be normally distributed.

One notable computational difference between finding confidence intervals for propritions as compared to those for means is how we find the underlying standard deviation. For numerical data, we simply estimate the population standard deviation with standard deviation for the sample. For a sample proportion, if we identify success (being left handed, for example) with a $1$ and failure as a $0$, then (as we know from our discussion of the binomial distribution) the resulting standard deviation is

$$\sigma = \sqrt{p(1-p)}.$$It follows that the standard error is

$$SE = \frac{\sigma}{\sqrt{n}} = \sqrt{\frac{p(1-p)}{n}}.$$Suppose we draw a random sample of 132 people and find that 16 of them have blue eyes. Use this data to write down a $95\%$ confidence interval for the proportion of people with blue eyes.

*Solution*: We have $\hat{p}=16/132 \approx 0.1212$ and

Thus, our confidence interval is

$$0.1212 \pm 2\times0.0284 = [0.0644, 0.178].$$If you read the details of political surveys, you're likely to come across the term "margin of error" at some point. For example, here's a story from the NYTimes published on Oct 29. The first few paragraphs read:

Quinnipiac University released polls in four major swing states on Thursday, showing former Vice President Joseph R. Biden Jr. leading in Pennsylvania, narrowly ahead in Ohio, and effectively tied with President Trump in Florida and Iowa.

Mr. Biden was ahead of Mr. Trump in Pennsylvania by seven points, 51 percent to 44 percent, and in Ohio by five points, 48 percent to 43 percent.

His lead in Pennsylvania was outside the margin of error of plus or minus 2.7 percentage points, while his lead in Ohio was just inside the margin of error of plus or minus 2.9 percentage points.

Can you see why "2.7 percentage points" was outside the margin of error in Pennsylvania while "2.9 percentage points" was inside the margin of error in Ohio?

Ultimately, we'd like to know more precisely where phrases like "the margin of error of plus or minus 2.7 percentage points" comes from. We can find some of that information by looking at the detailed information published on poll by Quinnipiac. There we see:

- 1,186 likely voters in Ohio were surveyed, with a margin of error of +/- 2.9 percentage points;
- 1,324 likely voters in Pennsylvania were surveyed, with a margin of error of +/- 2.7 percentage points.

When we write a confidence interval as
$$s \pm z^* \times SE,$$
Then, $z^* \times SE$ is the *margin of error*. Geometrically, it's the distance that the
interval extends in either direction from the measured statistic $s$.

So, where's the $\pm 2.7$ or $\pm 2.9$ or whatever come from?

Suppose we're writing down a confidence interval for a proportion. In this case, approve or disapprove. If the actual proportion is $p$ and our sample size is $n$, then the standard error is

$$\sqrt{\frac{p(1-p)}{n}}.$$In the Pennsylvania poll, $n = 1324$. Furthermore the *biggest* that $p(1-p)$ can be is
$1/4$. You can see this by taking a look at a graph:

In the Pennsylvania poll, the sample size was 1324. Thus, the standard error is at *most*

Now, for a $95\%$ confidence interval, we take $z^* = 2$ so that our margin of error is at most

$$ME \leq 2\times0.0137412 \approx 0.0274825.$$There's your 2.7 percentage points.

During Trump's presidency, Five Thirty Eight, maintained a running Trump approval rating page. The most recent A+ rated poll was conducted by Marist college for NPR. It determined an approval rating of 38% based on a survey of 1173 randomly selected adults.

**Problem**: Use the results of this survey to write down a 95% confidence interval for Trump's approval rating.

We have

$$SE \leq \sqrt{\frac{1/4}{n}} = \sqrt{\frac{1/4}{1173}}\approx0.0146.$$Thus, our confidence interval is

$$0.38 \pm 2\times0.0146 = [0.3508,0.4092].$$We have $\hat{p}=0.38$ yielding an estimate of the standard error of

$$SE = \sqrt{\frac{\hat{p}(1-\hat{p})}{n}} = \sqrt{\frac{0.38\times0.58}{1173}}\approx0.0137.$$According to our Normal Calculator, $z^*=1.959964$. Thus, our confidence interval should be

$$0.38 \pm 1.959964\times0.0137 = [0.353148,0.406852].$$Recall that the margin of error generally depends on three things:

- Confidence level,
- underlying standard deviation, and
- the
*sample size*.

Sometimes, we require a specific confidence level and margin of error and, for a sample proportion, the underling standard deviation $\sqrt{p(1-p)}$ is never larger than $1/2$. Thus, we can always obtain the desired confidence level and margin of error by choosing sample size large enough.

In order to choose the sample size, we simply set up the inequality

$$z^*\sqrt{\frac{p(1-p)}{n}} < ME,$$where $z^*$ corresponds to the desired confidence level and $ME$ is the desired confidence level. Since $\sqrt{p(1-p)}<1/2$, this simplfies to

$$z^*\frac{1/2}{\sqrt{n}} < ME \: \text{ or } \: n>\frac{{z^*}^2}{4ME^2}.$$Suppose we wish to determine the percentage of voters who support our candidate. We'd like a $95\%$ level of confidence to $\pm2\%$ points. What sample size should guarantee this?

**Simple solution**: For a 95% level of confidence, we might take $z^*=2$ together with the given margin of error $ME=0.02$ to get

Thus, a pollster would probably be happy with $n=2500$ folks in the poll.

We can get a more precise (possibly smaller) sample size by using more precise estimates to $z^*$. In fact, for the homework, you need three digits of precision for your $z^*$ multiplier. For 90, 95, and 99%, these are

Conf: | 90% | 95% | 99% |
---|---|---|---|

$z^*$ | 1.282 | 1.960 | 2.326 |

In the previous problem, we would have:

$$n>\frac{{z^*}^2}{4ME^2} = \frac{1.960^2}{2\times0.02^2} = 2400.$$Thus, the HW would like to see 2401.