diff --git a/.Rbuildignore b/.Rbuildignore index 315abd1..a3871e1 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -20,3 +20,5 @@ ^CRAN-SUBMISSION$ ^README\.html$ ^CODE_OF_CONDUCT\.md$ +^doc$ +^Meta$ diff --git a/.gitignore b/.gitignore index 13dfd2b..627ff70 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,5 @@ README.html docs inst/doc +/doc/ +/Meta/ diff --git a/README.Rmd b/README.Rmd index b95580a..96e367a 100644 --- a/README.Rmd +++ b/README.Rmd @@ -23,7 +23,7 @@ knitr::opts_chunk$set( [![CRAN](http://cranlogs.r-pkg.org/badges/grand-total/bbw)](https://CRAN.R-project.org/package=bbw) [![R-CMD-check](https://github.com/rapidsurveys/bbw/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/rapidsurveys/bbw/actions/workflows/R-CMD-check.yaml) [![test-coverage](https://github.com/rapidsurveys/bbw/actions/workflows/test-coverage.yaml/badge.svg)](https://github.com/rapidsurveys/bbw/actions/workflows/test-coverage.yaml) -[![codecov](https://codecov.io/gh/rapidsurveys/bbw/graph/badge.svg?token=edgQexvxhi)](https://codecov.io/gh/rapidsurveys/bbw) +[![codecov](https://codecov.io/gh/rapidsurveys/bbw/graph/badge.svg?token=edgQexvxhi)](https://app.codecov.io/gh/rapidsurveys/bbw) [![CodeFactor](https://www.codefactor.io/repository/github/rapidsurveys/bbw/badge)](https://www.codefactor.io/repository/github/rapidsurveys/bbw) [![DOI](https://zenodo.org/badge/117305174.svg)](https://doi.org/10.5281/zenodo.6594797) diff --git a/README.md b/README.md index afd551b..e0579bc 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ stable](https://img.shields.io/badge/lifecycle-stable-brightgreen.svg)](https:// [![CRAN](http://cranlogs.r-pkg.org/badges/grand-total/bbw)](https://CRAN.R-project.org/package=bbw) [![R-CMD-check](https://github.com/rapidsurveys/bbw/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/rapidsurveys/bbw/actions/workflows/R-CMD-check.yaml) [![test-coverage](https://github.com/rapidsurveys/bbw/actions/workflows/test-coverage.yaml/badge.svg)](https://github.com/rapidsurveys/bbw/actions/workflows/test-coverage.yaml) -[![codecov](https://codecov.io/gh/rapidsurveys/bbw/graph/badge.svg?token=edgQexvxhi)](https://codecov.io/gh/rapidsurveys/bbw) +[![codecov](https://codecov.io/gh/rapidsurveys/bbw/graph/badge.svg?token=edgQexvxhi)](https://app.codecov.io/gh/rapidsurveys/bbw) [![CodeFactor](https://www.codefactor.io/repository/github/rapidsurveys/bbw/badge)](https://www.codefactor.io/repository/github/rapidsurveys/bbw) [![DOI](https://zenodo.org/badge/117305174.svg)](https://doi.org/10.5281/zenodo.6594797) @@ -121,10 +121,10 @@ follows: citation("bbw") #> To cite bbw in publications use: #> -#> Mark Myatt, Ernest Guevarra (2025). _bbw: Blocked -#> Weighted Bootstrap_. doi:10.5281/zenodo.6594797 -#> , R package -#> version 0.2.3, . +#> Mark Myatt, Ernest Guevarra (2025). _bbw: Blocked Weighted +#> Bootstrap_. doi:10.5281/zenodo.6594797 +#> , R package version 0.2.3, +#> . #> #> A BibTeX entry for LaTeX users is #> diff --git a/inst/WORDLIST b/inst/WORDLIST index 2f4c7e3..2ab9ff7 100644 --- a/inst/WORDLIST +++ b/inst/WORDLIST @@ -29,5 +29,6 @@ codecov df doi psu +runtimes sd th diff --git a/pkgdown/_pkgdown.yml b/pkgdown/_pkgdown.yml index 142cea0..8aec48c 100644 --- a/pkgdown/_pkgdown.yml +++ b/pkgdown/_pkgdown.yml @@ -20,11 +20,13 @@ navbar: left: [home, intro, reference, articles, news] right: [search, mastodon, linkedin, github] components: - # articles: - # text: Articles - # menu: - # - text: "The RAM-OP Workflow" - # href: articles/ram_op_workflow.html + articles: + text: Articles + menu: + - text: "Blocked weighted bootstrap estimation" + href: articles/bbw-estimation.html + - text: "Using bbw with parallel computation" + href: articles/bbw-parallel.html mastodon: icon: "fab fa-mastodon fa-lg" aria-label: Mastodon @@ -34,7 +36,6 @@ navbar: aria-label: LinkedIn href: https://www.linkedin.com/company/katilingban - home: #links: #- text: Read more about haemoglobin concentrations for the diagnosis of anaemia and assessment of severity diff --git a/tests/testthat/test-boot_bw.R b/tests/testthat/test-boot_bw.R index 09bafe3..b28e67f 100644 --- a/tests/testthat/test-boot_bw.R +++ b/tests/testthat/test-boot_bw.R @@ -14,6 +14,7 @@ test_that("boot_bw_weight works as expected", { ), "integer" ) + expect_message(boot_bw_weight(boot_bw_weight(villageData))) }) mean_boot <- boot_bw( diff --git a/vignettes/bbw-parallel.Rmd b/vignettes/bbw-parallel.Rmd new file mode 100644 index 0000000..6c0defe --- /dev/null +++ b/vignettes/bbw-parallel.Rmd @@ -0,0 +1,1712 @@ +--- +title: "Using bbw with parallel computation" +author: "Ernest Guevarra" +date: "12 January 2025" +output: rmarkdown::html_vignette +vignette: > + %\VignetteIndexEntry{Using bbw with parallel computation} + %\VignetteEngine{knitr::rmarkdown} + %\VignetteEncoding{UTF-8} +--- + + + + + +A key feature of the most recent `{bbw}` update is its new function set that uses parallelisation for bootstrap resampling. This vignette explores the bootstrap resampling efficiencies gained with parallelisation. + +Applying the original and the alternative function/set to the Somalia survey dataset available from this package, bootstrap resampling is applied using the same parameters and the time the operation it takes to run is measured and compared. + +## Bootstrap resampling without parallelisation + +In this comparison, the original and alternative function/set both implement *sequential* bootstrap resampling with number of *parameters* set at varying values. + +### Using one parameter and 400 replicates + + +``` r +## Original bootstrap ---- +boot_orig_1_param <- system.time( + boot1_results <- bootBW( + x = indicatorsHH, w = villageData, statistic = bootClassic, params = "anc1" + ) |> + lapply( + FUN = quantile, + probs = c(0.5, 0.025, 0.975) + ) +) + +## Alternative bootstrap ---- +boot_alt_1_param <- system.time( + boot2_results <- boot_bw( + x = indicatorsHH, w = villageData, statistic = bootClassic, params = "anc1" + ) |> + boot_bw_estimate() +) +``` + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Original vs Alternative bootstrap resampling function/set
Sequential resampling with 1 parameter and 400 replicates
UserSystemElapsed
Original - 400 replicates - 1 parameter31.5050.032000000000003631.4860000000008
Alternative - 400 replicates - 1 parameter25.956025.8919999999998
+
+ +Performing bootstrap resampling sequentially, the original function took **31.486** seconds to run while the alternative function set took **25.892** seconds to run. There was very little difference between the original and the alternative function/set. + +### Using varying number of parameters and 400 replicates + + +``` r +## Original bootstrap ---- +boot_orig_2_param <- system.time( + boot1_results <- bootBW( + x = indicatorsHH, w = villageData, statistic = bootClassic, + params = c("anc1", "anc2") + ) |> + lapply( + FUN = quantile, + probs = c(0.5, 0.025, 0.975) + ) +) + +boot_orig_4_param <- system.time( + boot1_results <- bootBW( + x = indicatorsHH, w = villageData, statistic = bootClassic, + params = c("anc1", "anc2", "anc3", "anc4") + ) |> + lapply( + FUN = quantile, + probs = c(0.5, 0.025, 0.975) + ) +) + +boot_orig_8_param <- system.time( + boot1_results <- bootBW( + x = indicatorsHH, w = villageData, statistic = bootClassic, + params = c( + "anc1", "anc2", "anc3", "anc4", "hhs1", "hhs2", "hhs3", "hhs4" + ) + ) |> + lapply( + FUN = quantile, + probs = c(0.5, 0.025, 0.975) + ) +) + +## Alternative bootstrap ---- +boot_alt_2_param <- system.time( + boot2_results <- boot_bw( + x = indicatorsHH, w = villageData, statistic = bootClassic, + params = c("anc1", "anc2") + ) |> + boot_bw_estimate() +) + +boot_alt_4_param <- system.time( + boot2_results <- boot_bw( + x = indicatorsHH, w = villageData, statistic = bootClassic, + params = c("anc1", "anc2", "anc3", "anc4") + ) |> + boot_bw_estimate() +) + +boot_alt_8_param <- system.time( + boot2_results <- boot_bw( + x = indicatorsHH, w = villageData, statistic = bootClassic, + params = c( + "anc1", "anc2", "anc3", "anc4", "hhs1", "hhs2", "hhs3", "hhs4" + ) + ) |> + boot_bw_estimate() +) +``` + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Original vs Alternative bootstrap resampling function/set
Sequential resampling with increasing number of parameters and 400 replicates
No. of parametersUser - OriginalSystem - OriginalElapsed - OriginalUser - AlternativeSystem - AlternativeElapsed - Alternative
131.5050.03231.48625.956025.892
232.4420.00032.36325.747025.690
432.4850.00032.40425.302025.244
831.7270.00031.65225.660025.604
+
+ +There are marginal gains with the alternative function set when the number of parameters more than 1 but the gains do not increase with the increase in the number of parameters. + +## Bootstrap resampling with parallelisation + +In this comparison, the alternative function/set implements *parallel* bootstrap resampling with number of *parameters* set at varying values and number of parallel cores set at varying values and then compared to performance of the original function as above. + + +``` r +## Alternative bootstrap - 2 cores ---- +boot_alt_1_param_2_cores <- system.time( + boot2_results <- boot_bw( + x = indicatorsHH, w = villageData, statistic = bootClassic, + params = "anc1", parallel = TRUE, cores = 2 + ) |> + boot_bw_estimate() +) + +boot_alt_2_param_2_cores <- system.time( + boot2_results <- boot_bw( + x = indicatorsHH, w = villageData, statistic = bootClassic, + params = c("anc1", "anc2"), parallel = TRUE, cores = 2 + ) |> + boot_bw_estimate() +) + +boot_alt_4_param_2_cores <- system.time( + boot2_results <- boot_bw( + x = indicatorsHH, w = villageData, statistic = bootClassic, + params = c("anc1", "anc2", "anc3", "anc4"), parallel = TRUE, cores = 2 + ) |> + boot_bw_estimate() +) + +boot_alt_8_param_2_cores <- system.time( + boot2_results <- boot_bw( + x = indicatorsHH, w = villageData, statistic = bootClassic, + params = c( + "anc1", "anc2", "anc3", "anc4", "hhs1", "hhs2", "hhs3", "hhs4" + ), parallel = TRUE, cores = 2 + ) |> + boot_bw_estimate() +) + + +## Alternative bootstrap - 4 cores ---- +boot_alt_1_param_4_cores <- system.time( + boot2_results <- boot_bw( + x = indicatorsHH, w = villageData, statistic = bootClassic, + params = "anc1", parallel = TRUE, cores = 4 + ) |> + boot_bw_estimate() +) + +boot_alt_2_param_4_cores <- system.time( + boot2_results <- boot_bw( + x = indicatorsHH, w = villageData, statistic = bootClassic, + params = c("anc1", "anc2"), parallel = TRUE, cores = 4 + ) |> + boot_bw_estimate() +) + +boot_alt_4_param_4_cores <- system.time( + boot2_results <- boot_bw( + x = indicatorsHH, w = villageData, statistic = bootClassic, + params = c("anc1", "anc2", "anc3", "anc4"), parallel = TRUE, cores = 4 + ) |> + boot_bw_estimate() +) + +boot_alt_8_param_4_cores <- system.time( + boot2_results <- boot_bw( + x = indicatorsHH, w = villageData, statistic = bootClassic, + params = c( + "anc1", "anc2", "anc3", "anc4", "hhs1", "hhs2", "hhs3", "hhs4" + ), parallel = TRUE, cores = 4 + ) |> + boot_bw_estimate() +) + + +## Alternative bootstrap - 8 cores ---- +boot_alt_1_param_8_cores <- system.time( + boot2_results <- boot_bw( + x = indicatorsHH, w = villageData, statistic = bootClassic, + params = "anc1", parallel = TRUE, cores = 8 + ) |> + boot_bw_estimate() +) + +boot_alt_2_param_8_cores <- system.time( + boot2_results <- boot_bw( + x = indicatorsHH, w = villageData, statistic = bootClassic, + params = c("anc1", "anc2"), parallel = TRUE, cores = 8 + ) |> + boot_bw_estimate() +) + +boot_alt_4_param_8_cores <- system.time( + boot2_results <- boot_bw( + x = indicatorsHH, w = villageData, statistic = bootClassic, + params = c("anc1", "anc2", "anc3", "anc4"), parallel = TRUE, cores = 8 + ) |> + boot_bw_estimate() +) + +boot_alt_8_param_8_cores <- system.time( + boot2_results <- boot_bw( + x = indicatorsHH, w = villageData, statistic = bootClassic, + params = c( + "anc1", "anc2", "anc3", "anc4", "hhs1", "hhs2", "hhs3", "hhs4" + ), parallel = TRUE, cores = 8 + ) |> + boot_bw_estimate() +) +``` + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Original vs Alternative bootstrap resampling function/set
Parallel resampling with increasing number of parameters and increasing number of cores
No. of parametersOriginalAlternative - sequentialAlternative - 2 coresAlternative - 4 coresAlternative - 8 cores
131.48625.89216.90410.3927.361
232.36325.69016.75410.6347.398
432.40425.24417.01710.5457.585
831.65225.60417.56810.2407.624
+
+ +Parallelisation reduces runtimes by up to 50%. diff --git a/vignettes/bbw-parallel.Rmd.orig b/vignettes/bbw-parallel.Rmd.orig new file mode 100644 index 0000000..4183249 --- /dev/null +++ b/vignettes/bbw-parallel.Rmd.orig @@ -0,0 +1,347 @@ +--- +title: "Using bbw with parallel computation" +author: "Ernest Guevarra" +date: "12 January 2025" +output: rmarkdown::html_vignette +vignette: > + %\VignetteIndexEntry{Using bbw with parallel computation} + %\VignetteEngine{knitr::rmarkdown} + %\VignetteEncoding{UTF-8} +--- + +```{r, include = FALSE} +knitr::opts_chunk$set( + collapse = TRUE, + comment = "#>" +) +``` + +```{r setup, echo = FALSE} +library(bbw) +RNGkind("L'Ecuyer-CMRG") +set.seed(1977) +``` + +A key feature of the most recent `{bbw}` update is its new function set that uses parallelisation for bootstrap resampling. This vignette explores the bootstrap resampling efficiencies gained with parallelisation. + +Applying the original and the alternative function/set to the Somalia survey dataset available from this package, bootstrap resampling is applied using the same parameters and the time the operation it takes to run is measured and compared. + +## Bootstrap resampling without parallelisation + +In this comparison, the original and alternative function/set both implement *sequential* bootstrap resampling with number of *parameters* set at varying values. + +### Using one parameter and 400 replicates + +```{r boot-sequential, message = FALSE} +## Original bootstrap ---- +boot_orig_1_param <- system.time( + boot1_results <- bootBW( + x = indicatorsHH, w = villageData, statistic = bootClassic, params = "anc1" + ) |> + lapply( + FUN = quantile, + probs = c(0.5, 0.025, 0.975) + ) +) + +## Alternative bootstrap ---- +boot_alt_1_param <- system.time( + boot2_results <- boot_bw( + x = indicatorsHH, w = villageData, statistic = bootClassic, params = "anc1" + ) |> + boot_bw_estimate() +) +``` + +```{r boot-sequential-results, echo = FALSE} +data.frame( + cbind( + c( + "Original - 400 replicates - 1 parameter", + "Alternative - 400 replicates - 1 parameter" + ), + rbind(boot_orig_1_param, boot_alt_1_param) |> + (\(x) x[ , 1:3])() + ), + row.names = NULL +) |> + setNames(c(" ", "User", "System", "Elapsed")) |> + gt::gt() |> + gt::tab_header( + title = "Original vs Alternative bootstrap resampling function/set", + subtitle = "Sequential resampling with 1 parameter and 400 replicates" + ) +``` + +Performing bootstrap resampling sequentially, the original function took **`r boot_orig_1_param[3]`** seconds to run while the alternative function set took **`r boot_alt_1_param[3]`** seconds to run. There was very little difference between the original and the alternative function/set. + +### Using varying number of parameters and 400 replicates + +```{r boot-sequential-multi-params, message = FALSE} +## Original bootstrap ---- +boot_orig_2_param <- system.time( + boot1_results <- bootBW( + x = indicatorsHH, w = villageData, statistic = bootClassic, + params = c("anc1", "anc2") + ) |> + lapply( + FUN = quantile, + probs = c(0.5, 0.025, 0.975) + ) +) + +boot_orig_4_param <- system.time( + boot1_results <- bootBW( + x = indicatorsHH, w = villageData, statistic = bootClassic, + params = c("anc1", "anc2", "anc3", "anc4") + ) |> + lapply( + FUN = quantile, + probs = c(0.5, 0.025, 0.975) + ) +) + +boot_orig_8_param <- system.time( + boot1_results <- bootBW( + x = indicatorsHH, w = villageData, statistic = bootClassic, + params = c( + "anc1", "anc2", "anc3", "anc4", "hhs1", "hhs2", "hhs3", "hhs4" + ) + ) |> + lapply( + FUN = quantile, + probs = c(0.5, 0.025, 0.975) + ) +) + +## Alternative bootstrap ---- +boot_alt_2_param <- system.time( + boot2_results <- boot_bw( + x = indicatorsHH, w = villageData, statistic = bootClassic, + params = c("anc1", "anc2") + ) |> + boot_bw_estimate() +) + +boot_alt_4_param <- system.time( + boot2_results <- boot_bw( + x = indicatorsHH, w = villageData, statistic = bootClassic, + params = c("anc1", "anc2", "anc3", "anc4") + ) |> + boot_bw_estimate() +) + +boot_alt_8_param <- system.time( + boot2_results <- boot_bw( + x = indicatorsHH, w = villageData, statistic = bootClassic, + params = c( + "anc1", "anc2", "anc3", "anc4", "hhs1", "hhs2", "hhs3", "hhs4" + ) + ) |> + boot_bw_estimate() +) +``` + +```{r boot-sequential-multi-params-results, echo = FALSE} +data.frame( + n_params = c(1, 2, 4, 8), + rbind( + boot_orig_1_param, + boot_orig_2_param, + boot_orig_4_param, + boot_orig_8_param + )[ , 1:3], + rbind( + boot_alt_1_param, + boot_alt_2_param, + boot_alt_4_param, + boot_alt_8_param + )[ , 1:3], + row.names = NULL +) |> + setNames( + c( + "No. of parameters", + "User - Original", + "System - Original", + "Elapsed - Original", + "User - Alternative", + "System - Alternative", + "Elapsed - Alternative" + ) + ) |> + gt::gt() |> + gt::tab_header( + title = "Original vs Alternative bootstrap resampling function/set", + subtitle = "Sequential resampling with increasing number of parameters and 400 replicates" + ) +``` + +There are marginal gains with the alternative function set when the number of parameters more than 1 but the gains do not increase with the increase in the number of parameters. + +## Bootstrap resampling with parallelisation + +In this comparison, the alternative function/set implements *parallel* bootstrap resampling with number of *parameters* set at varying values and number of parallel cores set at varying values and then compared to performance of the original function as above. + +```{r boot-parallel, message = FALSE} +## Alternative bootstrap - 2 cores ---- +boot_alt_1_param_2_cores <- system.time( + boot2_results <- boot_bw( + x = indicatorsHH, w = villageData, statistic = bootClassic, + params = "anc1", parallel = TRUE, cores = 2 + ) |> + boot_bw_estimate() +) + +boot_alt_2_param_2_cores <- system.time( + boot2_results <- boot_bw( + x = indicatorsHH, w = villageData, statistic = bootClassic, + params = c("anc1", "anc2"), parallel = TRUE, cores = 2 + ) |> + boot_bw_estimate() +) + +boot_alt_4_param_2_cores <- system.time( + boot2_results <- boot_bw( + x = indicatorsHH, w = villageData, statistic = bootClassic, + params = c("anc1", "anc2", "anc3", "anc4"), parallel = TRUE, cores = 2 + ) |> + boot_bw_estimate() +) + +boot_alt_8_param_2_cores <- system.time( + boot2_results <- boot_bw( + x = indicatorsHH, w = villageData, statistic = bootClassic, + params = c( + "anc1", "anc2", "anc3", "anc4", "hhs1", "hhs2", "hhs3", "hhs4" + ), parallel = TRUE, cores = 2 + ) |> + boot_bw_estimate() +) + + +## Alternative bootstrap - 4 cores ---- +boot_alt_1_param_4_cores <- system.time( + boot2_results <- boot_bw( + x = indicatorsHH, w = villageData, statistic = bootClassic, + params = "anc1", parallel = TRUE, cores = 4 + ) |> + boot_bw_estimate() +) + +boot_alt_2_param_4_cores <- system.time( + boot2_results <- boot_bw( + x = indicatorsHH, w = villageData, statistic = bootClassic, + params = c("anc1", "anc2"), parallel = TRUE, cores = 4 + ) |> + boot_bw_estimate() +) + +boot_alt_4_param_4_cores <- system.time( + boot2_results <- boot_bw( + x = indicatorsHH, w = villageData, statistic = bootClassic, + params = c("anc1", "anc2", "anc3", "anc4"), parallel = TRUE, cores = 4 + ) |> + boot_bw_estimate() +) + +boot_alt_8_param_4_cores <- system.time( + boot2_results <- boot_bw( + x = indicatorsHH, w = villageData, statistic = bootClassic, + params = c( + "anc1", "anc2", "anc3", "anc4", "hhs1", "hhs2", "hhs3", "hhs4" + ), parallel = TRUE, cores = 4 + ) |> + boot_bw_estimate() +) + + +## Alternative bootstrap - 8 cores ---- +boot_alt_1_param_8_cores <- system.time( + boot2_results <- boot_bw( + x = indicatorsHH, w = villageData, statistic = bootClassic, + params = "anc1", parallel = TRUE, cores = 8 + ) |> + boot_bw_estimate() +) + +boot_alt_2_param_8_cores <- system.time( + boot2_results <- boot_bw( + x = indicatorsHH, w = villageData, statistic = bootClassic, + params = c("anc1", "anc2"), parallel = TRUE, cores = 8 + ) |> + boot_bw_estimate() +) + +boot_alt_4_param_8_cores <- system.time( + boot2_results <- boot_bw( + x = indicatorsHH, w = villageData, statistic = bootClassic, + params = c("anc1", "anc2", "anc3", "anc4"), parallel = TRUE, cores = 8 + ) |> + boot_bw_estimate() +) + +boot_alt_8_param_8_cores <- system.time( + boot2_results <- boot_bw( + x = indicatorsHH, w = villageData, statistic = bootClassic, + params = c( + "anc1", "anc2", "anc3", "anc4", "hhs1", "hhs2", "hhs3", "hhs4" + ), parallel = TRUE, cores = 8 + ) |> + boot_bw_estimate() +) +``` + +```{r boot-parallel-results, echo = FALSE} +data.frame( + n_params = c(1, 2, 4, 8), + rbind( + boot_orig_1_param, + boot_orig_2_param, + boot_orig_4_param, + boot_orig_8_param + )[ , 3], + rbind( + boot_alt_1_param, + boot_alt_2_param, + boot_alt_4_param, + boot_alt_8_param + )[ , 3], + rbind( + boot_alt_1_param_2_cores, + boot_alt_2_param_2_cores, + boot_alt_4_param_2_cores, + boot_alt_8_param_2_cores + )[ , 3], + rbind( + boot_alt_1_param_4_cores, + boot_alt_2_param_4_cores, + boot_alt_4_param_4_cores, + boot_alt_8_param_4_cores + )[ , 3], + rbind( + boot_alt_1_param_8_cores, + boot_alt_2_param_8_cores, + boot_alt_4_param_8_cores, + boot_alt_8_param_8_cores + )[ , 3], + row.names = NULL +) |> + setNames( + c( + "No. of parameters", + "Original", + "Alternative - sequential", + "Alternative - 2 cores", + "Alternative - 4 cores", + "Alternative - 8 cores" + ) + ) |> + gt::gt() |> + gt::tab_header( + title = "Original vs Alternative bootstrap resampling function/set", + subtitle = "Parallel resampling with increasing number of parameters and increasing number of cores" + ) +``` + +Parallelisation reduces runtimes by up to 50%. \ No newline at end of file diff --git a/vignettes/bbw.Rmd b/vignettes/bbw.Rmd index b0fe1fc..68aca40 100644 --- a/vignettes/bbw.Rmd +++ b/vignettes/bbw.Rmd @@ -55,7 +55,7 @@ Early versions of the `{bbw}` did not resample observations within PSUs followin
-> Cameron AC, Gelbach JB, Miller DL, Bootstrap-based improvements for inference with clustered errors, Review of Economics and Statistics, 2008:90;414–427 +> Cameron AC, Gelbach JB, Miller DL, Bootstrap-based improvements for inference with clustered errors, Review of Economics and Statistics, 2008:90;414–427 https://www.nber.org/papers/t0344