Skip to content

Instantly share code, notes, and snippets.

@brshallo
Created April 27, 2021 14:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brshallo/1349cc19e616e5d1df03cc7efe77e67a to your computer and use it in GitHub Desktop.
Save brshallo/1349cc19e616e5d1df03cc7efe77e67a to your computer and use it in GitHub Desktop.
Initial approach to bootstrapping a mean value, but is much slower than just using base::sample() so used that...
library(tidymodels)
### MUCH faster computationally to use base R `sample()` for this step... so did not use this approach
resamples <- rsample::bootstraps(preds, 5000)
avg_diff_sample <- function(split){
analysis(split) %>%
summarise(diff = mean(diff_abs_resids)) %>%
pull(diff)
}
resamples <- resamples %>%
transmute(diff = map_dbl(splits, avg_diff_sample))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment