1. Learn
  2. /
  3. Courses
  4. /
  5. Foundations of Inference in R

Exercise

Bootstrap percentile interval

The main idea in the previous exercise was that the distance between the original sample \(\hat{p}\) and the resampled (or bootstrapped) \(\hat{p}^*\) values gives a measure for how far the original \(\hat{p}\) is from the true population proportion.

The same variability can be measured through a different mechanism. As before, if \(\hat{p}\) is sufficiently close to the true parameter, then the resampled (bootstrapped) \(\hat{p}^*\) values will vary in such a way that they overlap with the true parameter.

Instead of using \(\pm 2 SE\) as a way to measure the middle 95% of the sampled \(\hat{p}\) values, you can find the middle of the resampled \(\hat{p}^*\) values by removing the upper and lower 2.5%. Note that this second method of constructing bootstrap intervals also gives an intuitive way for making 90% or 99% confidence intervals as well as 95% intervals.

The bootstrapped resamples, one_poll_boot, and the proportion of yes votes, p_hat are available in your workspace.

Instructions 1/3

undefined XP
  • 1
    • Run the code to remind yourself of the t-interval from the previous exercise.
    • Calculate the 95 percent interval of the bootstrapped \(\hat{p}^*\) values contained in one_poll_boot.
      • Summarize to calculate the lower end at the 2.5% quantile of stat by setting p to 0.025.
      • Calculate the upper end in a similar way.
  • 2

    Perform the same calculation using infer's convenience function, get_confidence_interval(). For the interval, use level = 0.95, and call the output percentile_ci.

  • 3
    • visualize() the distribution of bootstrapped proportions with the middle 95 percent highlighted.
      • Set the endpoints of the highlighted region to percentile_ci.
      • Set direction to "between" to highlight in-between those endpoints.