Constructing Confidence Intervals with the Pennies Sample

Learn how to construct confidence intervals.

Recall that the process of resampling with replacement we performed by hand and virtually is known as bootstrapping. The term bootstrapping originates in the expression of pulling oneself up by one’s bootstraps, which means to succeed only by one’s own efforts or abilities.

From a statistical perspective, bootstrapping refers to succeeding in being able to study the effects of sampling variation on estimates from the effort of a single sample. More precisely, it refers to constructing an approximation to the sampling distribution using only one sample.

To perform this resampling with replacement virtually, we used the rep_sample_n() function, making sure that the size of the resamples matched the original sample size of 50. In this lesson, we’ll build off these ideas to construct confidence intervals using a new package—the infer package—for tidy and transparent statistical inference.

Original workflow

Recall that we virtually performed bootstrap resampling with replacement to construct bootstrap distributions. Such distributions are approximations to the sampling distributions we saw, but are constructed using only a single sample. Let’s revisit the original workflow using the %>% pipe operator.

First, we use the rep_sample_n() function to resample size = 50 pennies with replacement from the original sample of 50 pennies in pennies_sample by setting replace = TRUE. Furthermore, we repeat this resampling 1,000 times by setting reps = 1000:

Get hands-on with 1200+ tech skills courses.