Percentile method - bootstrap CI for slope
Alternatively, a CI for the slope can be created using the percentiles of the distribution of the bootstrapped slope statistics. Recall that a CI is created in such a way that, over a lifetime of analysis, the coverage rate of a CI is (1-alpha)*100%. If you always set alpha = 0.05, then the 95% confidence intervals will capture the parameter of interest (over your lifetime) 95% of the time. Typically, out of the 5% of the time when the interval misses the parameter, sometimes the interval is too high (2.5% of the time) and sometimes the interval is too low (2.5% of the time).
The bootstrapped estimates of slope
, boot_slope
, are loaded in your workspace.
This exercise is part of the course
Inference for Linear Regression in R
Exercise instructions
- Set
alpha
to be 0.05 (although for your own work, feel free to use a different confidence level). - Calculate the relevant percentiles needed to create the confidence interval.
- The lower percentile cutoff is at half
alpha
. - The upper percentile cutoff is at one minus half
alpha
.
- The lower percentile cutoff is at half
- Create the confidence interval of
stat
usingquantile()
and the percentile cutoffs. Your interval ends should be namedlower
andupper
.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Set alpha
alpha <- ___
# Set the lower percentile cutoff
p_lower <- ___
# Set the upper percentile cutoff
p_upper <- ___
# Create a confidence interval of stat using quantiles
boot_slope %>%
___