14 3confintervals

# Confidence Intervals

.

We will now return to the idea of using one sample from the population to find an estimate for p (the population proportion)
.

Sometimes a single sample proportion $\big(\hat{p} \big)$ is called a point estimate for p.
.

From our work in the previous section (Distribution of sample proportions), we know that we cannot expect the sample proportion $\big(\hat{p} \big)$ of any one sample to exactly match the population proportion $\big( p \big)$
.

Our goal in this section, is to produce an interval either side of $\hat{p}$, so that we can say that the probability p lies within that interval is a given percentage.
.

This interval either side of $\hat{p}$ is called a Confidence Interval.

.

A Confidence Interval of 95% is very common.

ie, There is a probability of 95% that p lies in the interval:

… …$\Big( \hat{p} - c, \; \hat{p} + c \Big)$ … … for some value of c
.
or
.

… … $\text{Pr} \Big( \hat{p} - c < p < \hat{p} + c \Big) = 0.95$

.

We now assume that $\hat{p}$ is normally distributed with a mean of p

This is a reasonable assumption if the sample size is sufficiently large.
.

For the confidence interval to have a probability of 95%, it will need to be the same width as the width of the 95% area of the normal distribution curve.

.

Referring back to the Standard Normal Distribution (Z), we can use the Inverse Normal Distribution to find a such that:

… … $\text{Pr} \big(-a < z < a \big) = 0.95$
.

… …enter: InvNormCDF, $tail = center, \; p = 0.95,\; \sigma = 1, \; \mu = 0$

… … This gives a result of $a = \pm 1.96$
.

Note: If your calculator can only do left tail calculations, then you will need to find b such that:

… … $\text{Pr} \big( z < b \big) = \dfrac{1-0.95}{2} = 0.025$

… … This should also give a result of $b = -1.96$
.

Therefore,

… … $\text{Pr} \big(-1.96 < z < 1.96 \big) = 0.95$
.

Now we can use the rule to convert z into $\hat{p}$ given that $\mu = p$
.

… … $z = \dfrac{x - \mu}{\sigma} \qquad \Longrightarrow \qquad z = \dfrac{\hat{p} - p}{\sigma}$
.

… … $\text{Pr} \Big(-1.96 < \dfrac{\hat{p} - p}{\sigma} < 1.96 \Big) = 0.95$
.

… …$\text{Pr} \Big(-1.96\sigma < \hat{p} - p < 1.96\sigma \Big) = 0.95$
.

… … $\text{Pr} \Big(-\hat{p} - 1.96\sigma < - p < -\hat{p} + 1.96\sigma \Big) = 0.95$
.

… … $\text{Pr} \Big(\hat{p} + 1.96\sigma > p > \hat{p} - 1.96\sigma \Big) = 0.95$
.

Or:

… … $\text{Pr} \Big(\hat{p} - 1.96\sigma < p < \hat{p} + 1.96\sigma \Big) = 0.95$
.

We know that the theoretical standard deviation is given by: $\sigma = \sqrt{ \dfrac{p(1-p)}{n} }$
.

But in a practical situation, we don't know the actual value of p
.

So we use $\hat{p}$ as an approximate value for p and we get:
.

… … $\sigma \approx \sqrt{ \dfrac{ \hat{p} \big( 1 - \hat{p} \big) }{n} }$
.

So, the 95% confidence interval is given by:
.

… … $\text{Pr} \left( \hat{p} - 1.96\sqrt{ \dfrac{ \hat{p} \big( 1 - \hat{p} \big) }{n}} < p < \hat{p} + 1.96\sqrt{ \dfrac{ \hat{p} \big( 1 - \hat{p} \big) }{n}} \right) \approx 0.95$
.

or
.

Th 95% Confidence Interval is:
.

… … $\left( \hat{p} - 1.96\sqrt{ \dfrac{ \hat{p} \big( 1 - \hat{p} \big) }{n}} , \; \hat{p} + 1.96\sqrt{ \dfrac{ \hat{p} \big( 1 - \hat{p} \big) }{n}} \right)$

.

Note: the constant 1.96 came from the z-score where the central region was 95%

If we need to find a different confidence interval, we simply replace 1.96 with the new z-score.

.

### Example 1

The lengths of stay in hospital among patients is of interest to health planners. A random sample of 100 patients was investigated, and 20 were found to have stayed longer than 7 days.

a) .. Find a point estimate for p, the proportion of patients who stay in hospital longer than 7 days.

b) .. Calculate a 95% confidence interval for p.

Solution

a) .. Find a point estimate for p, the proportion of patients who stay in hospital longer than 7 days.

… … … $\hat{p} = \dfrac{\text{num successes}}{\text{num in sample (n)}}$
.

… … … $\hat{p} = \dfrac{20}{100}$
.

… … … $\hat{p} = 0.2$

.

b) .. Calculate a 95% confidence interval for p.
.

… … … $\text{Pr} \left( \hat{p} - 1.96\sqrt{ \dfrac{ \hat{p} \big( 1 - \hat{p} \big) }{n}} < p < \hat{p} + 1.96\sqrt{ \dfrac{ \hat{p} \big( 1 - \hat{p} \big) }{n}} \right) \approx 0.95$
.

… … … $\text{Pr} \left( 0.2 - 1.96\sqrt{ \dfrac{ 0.2 \big( 1 - 0.2 \big) }{100}} < p < 0.2 + 1.96\sqrt{ \dfrac{ 0.2 \big( 1 - 0.2 \big) }{100}} \right) \approx 0.95$
.

… … … $\text{Pr} \Big( 0.2 - 0.0784 < p < 0.2 + 0.0784 \Big) \approx 0.95$
.

… … … $\text{Pr} \Big(0.1216 < p < 0.2784 \Big) \approx 0.95$
.

## Using the CAS to calculate Confidence Intervals

.

Fortunately, the Classpad can do these calculations for us.

• Go to the Statistics Section, then the Calc menu and select Interval
• Select One-Prop Z Int and tap Next
• For C-Level (Confidence Level) Enter: 0.95
• For X (num of successes in sample) Enter: 20
• For n (size of sample) Enter 100
• Tap Next

The calculator should return:

So the 95% Confidence Interval is: $\Big( 0.1216, \; 0.2784\Big)$

• We are 95% sure that the value of p is in this range
• Where p is the proportion of all patients at the hospital who stay longer than 7 days.

.

## Changing the Level of Confidence

.

In general, the C% confidence interval will be given by:

… … $\left( \hat{p} - k\sqrt{ \dfrac{ \hat{p} \big( 1 - \hat{p} \big) }{n}} , \; \hat{p} + k\sqrt{ \dfrac{ \hat{p} \big( 1 - \hat{p} \big) }{n}} \right)$
.

Where k is found such that:

… … $Pr \Big( -k < z < k \Big) = \dfrac{C}{100}$

### Example 2:

Find the general form of the 68% Confidence Interval

Solution

… … Find the general form of the 68% Confidence Interval
.

… … … Use CAS (inverse normalcdf) to:
.

… … … find k such that $Pr \Big( -k < z < k \Big) = 0.68$
.

… … … returns $k = 0.9945$
.

… … … Hence 68% Confidence Interval is
.

… … $\left( \hat{p} - 0.9945\sqrt{ \dfrac{ \hat{p} \big( 1 - \hat{p} \big) }{n}} , \; \hat{p} + 0.9945\sqrt{ \dfrac{ \hat{p} \big( 1 - \hat{p} \big) }{n}} \right)$

.

### Example 3

Grow Well are 95% sure that 30% to 40% of shoppers prefer their mulch. What sample size was needed for this level of confidence?

Solution

… … In Notation we have: $Pr\big( 0.3 < p < 0.4\big) = 0.95$
.

… … clearly $\hat{p} = \dfrac{0.3+0.4}{2} = 0.35$
.

… … Compare this information with:

… … $\left( \hat{p} - 1.96\sqrt{ \dfrac{ \hat{p} \big( 1 - \hat{p} \big) }{n}} , \; \hat{p} + 1.96\sqrt{ \dfrac{ \hat{p} \big( 1 - \hat{p} \big) }{n}} \right)$
.

… … And we get that
.

… … … … $\hat{p} - 1.96\sqrt{ \dfrac{ \hat{p} \big( 1 - \hat{p} \big) }{n}} = 0.3$
.

… … … … $0.35 - 1.96\sqrt{ \dfrac{ 0.35 \big( 1 - 0.35 \big) }{n}} = 0.3$
.

… … … … which can be solved for n
.

… … … … $n = 349.59$ … … {round off because n is an integer}
.

… … … … $n = 350$ … … {required sample size}
.