# Lab 7 - Confidence Interval for a population mean and prop.

The class video is attached here so that you can watch my lecture again when you prepare the exams.

- If you have questions about my lecture, please use
**the comment section**at the bottom of this documents.

## Confidence interval for population mean (Known \(\sigma\))

We have learned that the sampling distribution of \(\overline{X}\) follows Normal distribution: \[ \mathcal{N}(\mu, \frac{\sigma}{\sqrt{n}}) \] where \(\mu\), \(\sigma\), and \(n\) represent the population mean, the population std., and the sample size, respectively.

Confidence interval for \(\mu\) can be constructed by

\[ from \quad \overline{x} - z^{*}\frac{\sigma}{\sqrt{n}} \quad to \quad \overline{x} + z^{*}\frac{\sigma}{\sqrt{n}} \] where \(z^{*}\) represents the critical value which depends on the confidence level C as follows:

Confidence Level C | 90% | 95% | 99% |
---|---|---|---|

Critical value z | 1.645 | 1.960 | 2.576 |

### Example

Issac wants to figure out what is the average percent of the tip in the U of Iowa restaurant. Thus, he recorded the percetage of the 20 tips of the total bill from 20 customers in the restaurant as follows:

```
## [1] "15.4 %" "19.8 %" "22.3 %" "12 %" "20.3 %" "20.5 %" "17.3 %" "17.4 %"
## [9] "17.3 %" "16.3 %" "17.6 %" "16 %" "16.7 %" "19.2 %" "21.9 %" "18.7 %"
## [17] "17.5 %" "16.3 %" "16.5 %" "26.2 %"
```

Issac knows that the std. of his restaurant tip percentage, \(\sigma\), is 3.

**Question 1**. How can you estimate the average percentage of the tip in his store?

**Question 2**. If you really want to make sure about your estimation of the mean percentage, you would rather build an interval. How can you construct an interval for estimate the mean percentage with a 95 confidence?

## Confidence interval for population mean: `proc means`

We have learned that `proc means`

provides more compact information than `proc univariate`

. Further SAS `proc means`

computes **confidence intervals for population means** without
making the unrealistic assumption that we know the the population standard deviation \(\sigma\).

```
data tips;
input percentage;
datalines ;
23.3
15.8
...
< copy data in here>
...
23.8
15.5
;
run ;
```

Let us calculate the summary statistics using `proc means`

as follows:

```
proc means;
var percentage;
run ;
```

Using this information, we can construct the 95% confidence interval for the population mean percent of the tip in Issac’s restaurant.

### Unknown \(\sigma\) (Chap. 18)

**Question 3**. What if Issac does not have any information about the population std. of the tip percentage in his store? How can he construct an interval for estimate the mean percentage with a 95 confidence?

Confidence interval for \(\mu\) without the infomation about \(\sigma\) can be constructed by \[ from \quad \overline{x} - t^{*}\frac{s}{\sqrt{n}} \quad to \quad \overline{x} + t^{*}\frac{s}{\sqrt{n}} \] where \(s\) indicates the sample std., \(t^*\) in indicates a different distribution (but very similar)! This can be done in SAS as follows:

```
proc means n mean clm ;
var percentage;
run ;
```

## Confidence interval for population proportion

We have learned the distribution of sample mean last week. Later chapter, we will learn the distribution of sample proportion!

For large sample size \(n\), we can say:

\[ \hat{p} \sim \mathcal{N}(p, \sqrt{\frac{p(1-p)}{n}}) \]

How can we use this fact to infer the population mean?

- Estimate for \(p\): \(\hat{p} = \frac{num. of successes}{n}\)
- C.I. for \(p\)

\[ from \quad \hat{p} - z^{*}\sqrt{\frac{p(1-p)}{n}} \quad to \quad \hat{p} + z^{*}\sqrt{\frac{p(1-p)}{n}} \]

This does not make any sense, since the whole point of doing this is to figure out what the \(p\) is! So, let’s just replace \(p\) with \(\hat{p}\)!

\[ from \quad \hat{p} - z^{*}\sqrt{\frac{\hat{p}(1-\hat{p})}{n}} \quad to \quad \hat{p} + z^{*}\sqrt{\frac{\hat{p}(1-\hat{p})}{n}} \]

Check this page out. Use right click and translate into English. What is the estimate of the death rate in china?

See this article and consider your opinion about the real death rate.