Exercise

# The bootstrap

Using this sample we would like to construct a bootstrap confidence interval for the average weight gained by *all* mothers during pregnancy. A quick reminder of how bootstrapping works:

- Take a bootstrap sample (a random sample with replacement of size equal to the original sample size) from the original sample.
- Record the mean of this bootstrap sample.
- Repeat steps (1) and (2) many times to build a bootstrap distribution.
- Calculate the XX% interval using the percentile or the standard error method.

Let's first take 100 bootstrap samples (i.e. with replacement), and record their means in a new object called `boot_means`

. You'll also make a histogram of the bootstrap distribution.

Instructions

**100 XP**

- Start by
**initializing**`boot_means`

with 100`NA`

values. - In a
**loop**, take a`sample`

of size`n`

(the original sample size) with replacement. You do this by setting the`replace`

argument of the`sample()`

function to`TRUE`

. - Store the mean of the sample in the corresponding element in
`boot_means`

. - Make a histogram of the bootstrap distribution
`boot_means`

.