Skip to content

Instantly share code, notes, and snippets.

View StefanM98's full-sized avatar

Stefan Milanovic StefanM98

View GitHub Profile
@StefanM98
StefanM98 / create-bootstrap
Created August 25, 2021 17:34
## Creating a 95% Bootstrap Confidence Interval for the sample standard deviation ### General Steps 1. Take the original sample, which has a sample size of sample_size, and treat it like the population. 2. Take a sample of size sample_size, with rep
create_bootstrap <- function (.data, num_samples, sample_size) {
# Create "num_samples" samples, of size "sample_size", from the original population ".data"
samples <- rerun(num_samples, sample(.data, sample_size, replace = TRUE))
# Find the standard deviation of each dataset
std_devs <- samples %>% map_dbl(sd)
# Find the bounds of the 95% confidence interval
interval <- std_devs %>% quantile(c(.025, .975))