almonds_sample_100 |>
specify(response = weight)the infer workflow, one verb at a time
resampling with replacement CI
specify()generate()calculate()get_confidence_interval()The mean weight of a bag of chocolate-covered almonds
You only ever get one sample. Bootstrapping asks what other samples like it would have looked like.
Resample Your Sample
Name the variable you are studying. Nothing is computed yet: this only records meta-data about the question.
Name Your Variable
Give it a response variable, or a formula y ~ x for two variables.
Example
the data frame
the verb (function) which variable you are studying
Build the resamples. type = “bootstrap” draws from your sample with replacement, as many times as reps says.
Resample A Thousand Times
Example
the data frame
the verb (function) how many resamples resample with replacement
Reduce every resample to one number. stat names which statistic: a mean, a proportion, a difference, a slope.
One Number Per Resample
The result has one row per replicate, and that is the bootstrap distribution.
the bootstrap distribution, saved for later
the verb (function) which statistic, for each resample
Take the middle 95% of the bootstrap distribution and report its two endpoints.
Example
the bootstrap distribution
the verb (function) how confident cut at the 2.5th and 97.5th percentiles
Plot the bootstrap distribution and shade the interval on top of it.
Example
the bootstrap distribution
shade the interval the two endpoints you just computed
The sentence to write, and the one to avoid.
Interpreting A 95% CI