This range of plausible values is known as a confidence interval and will be the focus of the later sections of this chapter. Recall from our discussion in Section 5. You will need to load the packages separately.

### Meet your instructors

If needed, read Section 2. Try to imagine all pennies being used in the United States in One way to compute this value would be to gather up all pennies being used in the US, record the year, and compute the average. This would be near impossible! An image of these 50 pennies can be seen in Figure 9.

The moderndive package contains this data on our 50 sampled pennies. Based on these 50 sampled pennies, what can we say about all US pennies in ? Since year is a numerical variable, we use a histogram in Figure 9.

We observe a slightly left-skewed distribution since most values fall in between the s through s with only a few older than What is the average year for the 50 sampled pennies? Eyeballing the histogram it appears to be around This should all start sounding similar to what we did previously in Chapter 8! We summarize the correspondence between the sampling bowl exercise in Chapter 8 and our pennies exercise in Table 9.

Going back to our 50 sampled pennies in Figure 9. Recall that we also saw in Chapter 8 that such estimates are prone to sampling variation. For example, in this particular sample in Figure 9. If we obtained other samples of size 50 would we always observe exactly three pennies with the year of ? More than likely not.

We might observe none, or one, or two, or maybe even all 50! The same can be said for the other 26 unique years that are represented in our sample of 50 pennies. To study this sampling variation as we did in Chapter 8 , we need more than one sample. In our case with pennies, how would we obtain another sample? We would go to the bank and get another roll of 50 pennies! So what how can we study sample-to-sample variation when we have only a single sample as in our case? Just as different uses of the shovel in the bowl led to the different sample proportions red, different samples of 50 pennies will lead to different sample mean years.

However, how can we study the effect of sampling variation using only our single sample seen in Figure 9. Record the year somewhere. What we just performed was a resampling of the original sample of 50 pennies. We are not sampling 50 pennies from the population of all US pennies as we did in our trip to the bank.

However, why did we replace our resampled slip of paper back into the hat in Step 4? Because if we left the slip of paper out of the hat each time we performed Step 4, we would obtain the same 50 pennies, in the end, each time! In other words, replacing the slips of paper induces variation. Being more precise with our terminology, we just performed a resampling with replacement of the original sample of 50 pennies.

Note that the 50 values you obtained will almost certainly not be the same as ours. We display the 50 resampled pennies in Figure 9. Observe that while the general shape of the distribution of year is roughly similar, they are not identical. This is due to the variation induced by replacing the slips of paper each time we pull one out and recorded the year.

Recall from the previous section that the sample mean of the original sample of 50 pennies from the bank was Any guesses? We obtained a different mean year of What if we repeated several times this resampling exercise many times? Would we obtain the same sample mean year value each time? In other words, would our guess at the mean year of all pennies in the US in be exactly We recorded these values in a shared spreadsheet with 50 rows plus a header row and 35 columns; we display a snapshot of the first 10 rows and 5 columns in Figure 9.

What did each of our 35 friends obtain as the mean year? After grouping the rows by name , we summarize each group of rows with their mean year :. Observe the following about the histogram in Figure 9. What we just demonstrated in this activity is the statistical procedure known as bootstrap resampling with replacement.

We used resampling to mimic the sampling variation we observe from sample-to-sample as we did in Chapter 8 on sampling, but this time using a single sample from the population. In fact, the histogram of sample means from 35 resamples in Figure 9. In Section 9. We can use a computer to do the resampling many more times than our 35 friends could possibly do. This will allow us to better understand the bootstrap distribution. The chapter concludes with a comparison of the sampling distribution and a bootstrap distribution using the balls data from Chapter 8 on sampling.

## Observed Confidence Levels: Theory and Application

Note also that the size argument is set to match the original sample size of 50 pennies. As when we did our tactile resampling, the resulting mean year is different than that mean year of our 50 originally sampled pennies of What did each of our 35 virtual friends obtain as the mean year? Furthermore, they are an approximation to the sampling distribution of the sample mean, a concept you saw in Chapter 8 on sampling. These distributions allow us to study the effect of sampling variation on our estimates of the true population mean, in this case the true mean year for all US pennies.

However, unlike in Chapter 8 where we simulated the act of taking multiple samples, something one would never do in practice, bootstrap distributions are constructed from a single sample, in this case the 50 original pennies from the bank. Remember that one of the goals of resampling with replacement is to construct the bootstrap distribution, which is an approximation of the sampling distribution of the point estimate of interest, here the sample mean year.

However, the bootstrap distribution of in Figure 9. Note here the bell shape starting to become more apparent. We now have a general sense for the range of values that the sample mean may take on in these resamples from this histogram of the bootstrap distribution. Do you have a guess as to where this histogram is centered? With it being close to symmetric, either the mean or the median would serve as a good estimate for the center here. The mean of the means from resamples is Note that this is quite close to the mean of our original sample of 50 pennies from the bank: This is the case since each of the resamples are based on the original sample of 50 pennies.

Say you are trying to catch a fish. On the one hand, you could use a spear, while on the other you could use a net.

### The folk theory of confidence intervals

Using the net will probably yield better results! Based on our sample of 50 pennies from the bank, the sample mean was Think of this value as fishing with a spear. Looking at the bootstrap distribution in Figure 9. While this question is somewhat subjective, saying that most sample means lie in the interval to would not be unreasonable. Think of this interval as fishing with a net.

We now introduce two methods for constructing such intervals in a more principled fashion: the percentile method and the standard error method.

## statistical theory | Richard D. Morey

Both methods for confidence interval construction share some commonalities. First, they are both constructed from the bootstrap distribution, an example of which you created using bootstrap resamples with replacement in Subsection 9. Second, they both require you to specify the confidence level. All other things being equal, higher confidence levels correspond to wider confidence intervals and lower confidence levels corresponding to narrower confidence intervals. The only way to know this value exactly would be to conduct a census of all pennies, a near impossible task.

We can do this by computing the 2. We can mark these percentiles on the bootstrap distribution with red vertical lines in Figure 9. Recall in Subsection 8. Given that our bootstrap distribution based on resamples with replacement in Figure 9. In other words, the bootstrap distribution is centered at What is this value?