diff --git a/CRAN-SUBMISSION b/CRAN-SUBMISSION index 790e6a20..0287cdbd 100644 --- a/CRAN-SUBMISSION +++ b/CRAN-SUBMISSION @@ -1,4 +1,3 @@ -Version: 0.14.0 -Date: 2023-07-09 19:55:48 UTC -SHA: - 431829b4d99cd13f0652e71483b3ce8e87cb5b58 +Version: 0.15.0 +Date: 2023-09-16 18:11:27 UTC +SHA: 47b7f6ad8815300458eca67327699ea865a8c878 diff --git a/DESCRIPTION b/DESCRIPTION index abb9d107..bef70675 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: fwildclusterboot Title: Fast Wild Cluster Bootstrap Inference for Linear Models -Version: 0.14.3 +Version: 0.15.0 Authors@R: c( person("Alexander", "Fischer", , "alexander-fischer1801@t-online.de", role = c("aut", "cre")), person("David", "Roodman", role = "aut"), diff --git a/NAMESPACE b/NAMESPACE index 4596da39..ffde1ecb 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -30,11 +30,11 @@ export(glance) export(mboottest) export(pval) export(setBoottest_engine) +export(setBoottest_nthreads) export(teststat) export(tidy) importFrom(JuliaConnectoR,juliaEval) importFrom(JuliaConnectoR,juliaImport) -importFrom(Matrix,Diagonal) importFrom(Matrix,Matrix) importFrom(Matrix,crossprod) importFrom(Matrix,sparse.model.matrix) @@ -64,6 +64,7 @@ importFrom(rlang,warn) importFrom(stats,aggregate) importFrom(stats,as.formula) importFrom(stats,coef) +importFrom(stats,confint) importFrom(stats,expand.model.frame) importFrom(stats,formula) importFrom(stats,model.frame) diff --git a/NEWS.md b/NEWS.md index 91ed8afd..571d1d11 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,39 @@ +# CRAN release: fwildclusterboot 0.15 + +- For rademacher weights, switches to `dqrng::dqrrademacher`. This leads to substabtial + performance increases (see below). But the random number generation changes slightly, so + you might no longer reproduce exactly the same weights draw under the same seeds, and in turn, + your bootstrap inferences might change slightly. +- For other changes, see the changelog for versions `0.13-0.14.3`, all of which have not + been published on CRAN. +- The package's lifecycle badge has been changed to `stable`, as there have not been any breaking API + changes in a while, and I do not plan any in the future. + +```r + > library(bench) +> +> n <- 999999 * 100 +> +> mark( ++ dqrrademacher(n), ++ dqrng::dqsample( ++ x = c(-1L, 1L), ++ size = n, ++ replace = TRUE ++ ), ++ iterations = 5, ++ check = FALSE ++ ) +# A tibble: 2 × 13 + expression min median itr/s…¹ mem_a…² gc/se…³ n_itr n_gc + +1 dqrrademacher(n) 123ms 166ms 5.25 381MB 3.15 5 3 +2 dqrng::dqsample(x = c(-1L, 1L), size = n, replace = TRUE) 615ms 647ms 1.47 763MB 1.47 5 5 +# … with 5 more variables: total_time , result , memory , time , gc , and +# abbreviated variable names ¹​`itr/sec`, ²​mem_alloc, ³​`gc/sec` +``` + + # fwildclusterboot 0.14.3 - Fix a bug with CI inversion when `r` was set to be close to the estimated parameter. (CI inversion failed). See [#138](https://github.com/s3alfisc/fwildclusterboot/issues/138). Thanks to Achim Zeileis & team for raising this issue! diff --git a/R/boot_algo_fastnwild.R b/R/boot_algo_fastnwild.R index aeb8b699..b18b4685 100644 --- a/R/boot_algo_fastnwild.R +++ b/R/boot_algo_fastnwild.R @@ -312,9 +312,9 @@ boot_algo_fastnwild <- if (impose_null == TRUE) { # should always be positive, point_estimate and t_stat need to have same # sign, abs for security - pval_peak <- abs(point_estimate) + pval_peak <- point_estimate } else if (impose_null == FALSE) { - pval_peak <- abs((point_estimate - r)) + pval_peak <- (point_estimate - r) } invert_p_val( diff --git a/R/boottest_felm.R b/R/boottest_felm.R index 9357cf2a..bdb3d678 100644 --- a/R/boottest_felm.R +++ b/R/boottest_felm.R @@ -421,6 +421,12 @@ boottest.felm <- function(object, } } } + + check_engine_btype( + engine = engine, + bootstrap_type = bootstrap_type + ) + if (!is.null(beta0)) { rlang::abort( @@ -454,14 +460,18 @@ boottest.felm <- function(object, if (is.null(clustid)) { heteroskedastic <- TRUE - if (engine == "R") { + if (engine %in% c("R", "WildBootTests.jl")) { # heteroskedastic models should always be run through R-lean engine <- "R-lean" + rlang::inform( + "The heteroskedastic bootstrap is only supported for `engine = 'R-lean'`, + Resetting the engine argument to 'R-lean'." + ) } } else { heteroskedastic <- FALSE } - + check_bootstrap_types( param = param, bootstrap_type = bootstrap_type @@ -492,7 +502,7 @@ boottest.felm <- function(object, fe = fe ) - preprocess <- preprocess2.felm( + preprocess <- preprocess_felm( object = object, clustid = clustid, R = R_long, diff --git a/R/boottest_fixest.R b/R/boottest_fixest.R index d3554b81..1bab09ae 100644 --- a/R/boottest_fixest.R +++ b/R/boottest_fixest.R @@ -431,7 +431,12 @@ boottest.fixest <- function(object, } } } - + + check_engine_btype( + engine = engine, + bootstrap_type = bootstrap_type + ) + if (!is.null(beta0)) { rlang::abort( c( @@ -481,14 +486,18 @@ boottest.fixest <- function(object, if (is.null(clustid)) { heteroskedastic <- TRUE - if (engine == "R") { + if (engine %in% c("R", "WildBootTests.jl")) { # heteroskedastic models should always be run through R-lean engine <- "R-lean" + rlang::inform( + "The heteroskedastic bootstrap is only supported for `engine = 'R-lean'`, + Resetting the engine argument to 'R-lean'." + ) } } else { heteroskedastic <- FALSE } - + check_bootstrap_types( param = param, bootstrap_type = bootstrap_type @@ -521,7 +530,7 @@ boottest.fixest <- function(object, ) # preprocess the data: Y, X, weights, fixed_effect - preprocess <- preprocess2.fixest( + preprocess <- preprocess_fixest( object = object, clustid = clustid, R = R_long, diff --git a/R/boottest_ivreg.R b/R/boottest_ivreg.R index fc60dd85..64b4374d 100644 --- a/R/boottest_ivreg.R +++ b/R/boottest_ivreg.R @@ -288,7 +288,7 @@ boottest.ivreg <- function(object, # preprocess data: X, Y, weights, fixed effects - preprocess <- preprocess2.ivreg( + preprocess <- preprocess_ivreg( object = object, clustid = clustid, R = R, diff --git a/R/boottest_lm.R b/R/boottest_lm.R index 4e310e74..f10cbd66 100644 --- a/R/boottest_lm.R +++ b/R/boottest_lm.R @@ -383,7 +383,7 @@ boottest.lm <- function(object, engine = engine, bootstrap_type = bootstrap_type ) - + if (!is.null(beta0)) { rlang::abort( c( @@ -413,14 +413,18 @@ boottest.lm <- function(object, if (is.null(clustid)) { heteroskedastic <- TRUE - if (engine == "R") { + if (engine %in% c("R", "WildBootTests.jl")) { # heteroskedastic models should always be run through R-lean engine <- "R-lean" + rlang::inform( + "The heteroskedastic bootstrap is only supported for `engine = 'R-lean'`, + Resetting the engine argument to 'R-lean'." + ) } } else { heteroskedastic <- FALSE } - + check_bootstrap_types( param = param, bootstrap_type = bootstrap_type @@ -453,7 +457,7 @@ boottest.lm <- function(object, # now split into R, R-lean and WildBootTests.jl algos # different pre-processing and different algo-functions - preprocess <- preprocess2.lm( + preprocess <- preprocess_lm( object = object, clustid = clustid, R = R_long, diff --git a/R/get_weights.R b/R/get_weights.R index 4f103021..becba2f1 100644 --- a/R/get_weights.R +++ b/R/get_weights.R @@ -29,11 +29,7 @@ get_weights <- function(type, # (uses less memory # than numeric) rademacher = function(n) { - dqrng::dqsample( - x = c(-1L, 1L), - size = n, - replace = TRUE - ) + dqrng::dqrrademacher(n) }, mammen = function(n) { sample( diff --git a/R/mboottest_felm.R b/R/mboottest_felm.R index 89d59446..7b723341 100644 --- a/R/mboottest_felm.R +++ b/R/mboottest_felm.R @@ -229,7 +229,7 @@ mboottest.felm <- function(object, fedfadj <- 0L - preprocess <- preprocess2.felm( + preprocess <- preprocess_felm( object = object, clustid = clustid, R = R, diff --git a/R/mboottest_fixest.R b/R/mboottest_fixest.R index 6d2dae34..cd74edda 100644 --- a/R/mboottest_fixest.R +++ b/R/mboottest_fixest.R @@ -255,7 +255,7 @@ mboottest.fixest <- function(object, fe = fe ) - preprocess <- preprocess2.fixest( + preprocess <- preprocess_fixest( object = object, clustid = clustid, R = R, diff --git a/R/mboottest_lm.R b/R/mboottest_lm.R index e3654f81..c7791b66 100644 --- a/R/mboottest_lm.R +++ b/R/mboottest_lm.R @@ -226,7 +226,7 @@ mboottest.lm <- function(object, # preprocess data: X, Y, weights, fixed effects - preprocess <- preprocess2.lm( + preprocess <- preprocess_lm( object = object, clustid = clustid, R = R, diff --git a/R/methods.R b/R/methods.R index 3cab1194..6efc1a29 100644 --- a/R/methods.R +++ b/R/methods.R @@ -52,7 +52,7 @@ #' #' @details Technical Details #' For technical details, either take a look at the references below, or check -#' out the [wild (cluster) bootstrap vignette](wild_bootstrap.html). +#' out the [wild (cluster) bootstrap vignette](https://s3alfisc.github.io/fwildclusterboot/articles/wild_bootstrap.html). #' #' @section Stata, Julia and Python Implementations: #' The fast wild cluster bootstrap algorithms are further implemented in the @@ -757,6 +757,7 @@ nobs.mboottest <- function(object, ...) { #' @param ... Further arguments passed to or from other methods. #' @param digits Number of rounding digits #' @export +#' @importFrom stats confint #' @method print boottest #' @return A scalar containing the effective number of observations #' used in `mboottest` @@ -780,16 +781,17 @@ print.boottest <- function(x, ..., digits = 4) { print(x$call) cat("", "\n") - vals <- lapply( - c("p_val", "conf_int", "t_stat"), - function(y) { - round(x[[y]], digits = digits) - } - ) + pval <- pval(x) + conf_int <- confint(x) + teststat <- teststat(x) - cat("p value:", vals[[1]], "\n") - cat("confidence interval:", vals[[2]], "\n") - cat("test statistic", vals[[3]], "\n") + pval <- round(pval, digits = digits) + teststat <- round(teststat, digits = digits) + conf_int <- ifelse(is.null(conf_int), NA, round(conf_int, digits)) + + cat("p value:", pval, "\n") + cat("confidence interval:", conf_int, "\n") + cat("test statistic", teststat, "\n") } diff --git a/R/onLoad.R b/R/onLoad.R index 3e38ff13..c83b060b 100644 --- a/R/onLoad.R +++ b/R/onLoad.R @@ -16,8 +16,17 @@ .onAttach <- function(libname, pkgname) { + + packageStartupMessage("\nNote that with version 0.15, rademacher weights are") + packageStartupMessage("drawn from `dqrng::dqrrademacher()` instead of `dqrng::dqsample()`.") + packageStartupMessage("This brings nice performance gains, but you might no longer be able to exactly reproduce") + packageStartupMessage("your bootstrap inferences under a given seed. If this is a ") + packageStartupMessage("requirement for you, please revert to `fwildclusterboot` version") + packageStartupMessage("0.13-0.14.3.") + packageStartupMessage("\nPlease cite as: \n") packageStartupMessage(" Fischer & Roodman. (2021). fwildclusterboot: Fast Wild Cluster.") packageStartupMessage(" Bootstrap Inference for Linear Regression Models.") packageStartupMessage(" Available from https://cran.r-project.org/package=fwildclusterboot/.") + } diff --git a/R/preprocess2.R b/R/preprocess_models.R similarity index 97% rename from R/preprocess2.R rename to R/preprocess_models.R index 74574564..ccd02c4e 100644 --- a/R/preprocess2.R +++ b/R/preprocess_models.R @@ -1,20 +1,4 @@ -#' `preprocess2` is a S3 method that fetches data from several model -#' objectects for use with `boottest()`. -#' -#' @param object An objectect of type lm, fixest, felm or ivreg -#' @param ... other arguments -#' @noRd -#' -#' @importFrom Matrix Diagonal -#' @return An object of class `preprocess2`. -#' @srrstats {G2.8} *Software should provide appropriate conversion or dispatch -#' routines as part of initial pre-processing to ensure that all other -#' sub-functions of a package receive inputs of a single defined class or -#' type.* Similar preprocess method + run_bootstrap function. -preprocess2 <- function(object, ...) { - UseMethod("preprocess2") -} -preprocess2.fixest <- +preprocess_fixest <- function(object, clustid, R, @@ -213,7 +197,7 @@ preprocess2.fixest <- } res } -preprocess2.felm <- +preprocess_felm <- function(object, clustid, R, @@ -388,7 +372,7 @@ preprocess2.felm <- } res } -preprocess2.lm <- +preprocess_lm <- function(object, clustid, R, @@ -492,7 +476,7 @@ preprocess2.lm <- class(res) <- c("preprocess", "ols") res } -preprocess2.ivreg <- +preprocess_ivreg <- function(object, clustid, R, @@ -1040,4 +1024,4 @@ get_cluster <- cluster_bootcluster = cluster_bootcluster_df ) res -} \ No newline at end of file +} diff --git a/R/utils.R b/R/utils.R index 18589d6c..ef0ff6a1 100644 --- a/R/utils.R +++ b/R/utils.R @@ -263,8 +263,8 @@ setBoottest_nthreads <- function(nthreads) { #' By default, only one thread is used #' @param nthreads Integer. Number of threads to be used #' @return No return value - #' @noRd #' @importFrom parallel detectCores + #' @export max_CRAN <- as.numeric(Sys.getenv("OMP_THREAD_LIMIT")) max_CRAN[is.na(max_CRAN)] <- 1000 @@ -397,16 +397,9 @@ to_integer <- function(vec) { # functions taken from 'clubSandwich' package matrix_split <- function (x, fac, dim) { - # if (is.vector(x)) { - # if (dim != "both") - # stop(paste0("Object must be a matrix in order to subset by ", - # dim, ".")) - # x_list <- split(x, fac) - # lapply(x_list, function(x) diag(x, nrow = length(x))) - # } - # else { - lapply(levels(fac), sub_f(x, fac, dim)) - #} + + lapply(levels(fac), sub_f(x, fac, dim)) + } sub_f <- function (x, fac, dim){ diff --git a/README.Rmd b/README.Rmd index 5737900d..0f41e2ca 100644 --- a/README.Rmd +++ b/README.Rmd @@ -22,7 +22,7 @@ knitr::opts_chunk$set( [![Status at rOpenSci Software Peer Review](https://badges.ropensci.org/546_status.svg)](https://github.com/ropensci/software-review/issues/546) -[![Lifecycle: maturing](https://img.shields.io/badge/lifecycle-maturing-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html) +[![Lifecycle: stable](https://img.shields.io/badge/lifecycle-maturing-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html) [![CRAN status](https://www.r-pkg.org/badges/version/fwildclusterboot)](https://CRAN.R-project.org/package=fwildclusterboot) ![runiverse-package](https://s3alfisc.r-universe.dev/badges/fwildclusterboot) [![R-CMD-check](https://github.com/s3alfisc/fwildclusterboot/workflows/R-CMD-check/badge.svg)](https://github.com/s3alfisc/fwildclusterboot/actions) diff --git a/README.md b/README.md index 9d8a0973..be66f255 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ [![Status at rOpenSci Software Peer Review](https://badges.ropensci.org/546_status.svg)](https://github.com/ropensci/software-review/issues/546) [![Lifecycle: -maturing](https://img.shields.io/badge/lifecycle-maturing-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html) +stable](https://img.shields.io/badge/lifecycle-maturing-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html) [![CRAN status](https://www.r-pkg.org/badges/version/fwildclusterboot)](https://CRAN.R-project.org/package=fwildclusterboot) ![runiverse-package](https://s3alfisc.r-universe.dev/badges/fwildclusterboot) @@ -141,7 +141,7 @@ citation("fwildclusterboot") #> A BibTeX entry for LaTeX users is #> #> @Misc{, -#> title = {fwildclusterboot: Fast Wild Cluster Bootstrap Inference for Linear Regression Models (Version 0.14.0)}, +#> title = {fwildclusterboot: Fast Wild Cluster Bootstrap Inference for Linear Regression Models (Version 0.14.3)}, #> author = {Alexander Fischer and David Roodman}, #> year = {2021}, #> url = {https://cran.r-project.org/package=fwildclusterboot}, diff --git a/codemeta.json b/codemeta.json deleted file mode 100644 index a88f46ee..00000000 --- a/codemeta.json +++ /dev/null @@ -1,457 +0,0 @@ -{ - "@context": "https://doi.org/10.5063/schema/codemeta-2.0", - "@type": "SoftwareSourceCode", - "identifier": "fwildclusterboot", - "description": "Implementation of fast algorithms for wild cluster bootstrap inference developed in 'Roodman et al' (2019, 'STATA' Journal, ) and 'MacKinnon et al' (2022), which makes it feasible to quickly calculate bootstrap test statistics based on a large number of bootstrap draws even for large samples. Multiple bootstrap types as described in 'MacKinnon, Nielsen & Webb' (2022) are supported. Further, 'multiway' clustering, regression weights, bootstrap weights, fixed effects and 'subcluster' bootstrapping are supported. Further, both restricted ('WCR') and unrestricted ('WCU') bootstrap are supported. Methods are provided for a variety of fitted models, including 'lm()', 'feols()' (from package 'fixest') and 'felm()' (from package 'lfe'). Additionally implements a 'heteroskedasticity-robust' ('HC1') wild bootstrap. Last, the package provides an R binding to 'WildBootTests.jl', which provides additional speed gains and functionality, including the 'WRE' bootstrap for instrumental variable models (based on models of type 'ivreg()' from package 'ivreg') and hypotheses with q > 1.", - "name": "fwildclusterboot: Fast Wild Cluster Bootstrap Inference for Linear Models", - "codeRepository": "https://github.com/s3alfisc/fwildclusterboot", - "issueTracker": "https://github.com/s3alfisc/fwildclusterboot/issues/", - "license": "https://spdx.org/licenses/GPL-3.0", - "version": "0.14.2", - "programmingLanguage": { - "@type": "ComputerLanguage", - "name": "R", - "url": "https://r-project.org" - }, - "runtimePlatform": "R version 4.2.1 (2022-06-23 ucrt)", - "provider": { - "@id": "https://cran.r-project.org", - "@type": "Organization", - "name": "Comprehensive R Archive Network (CRAN)", - "url": "https://cran.r-project.org" - }, - "author": [ - { - "@type": "Person", - "givenName": "Alexander", - "familyName": "Fischer", - "email": "alexander-fischer1801@t-online.de" - }, - { - "@type": "Person", - "givenName": "David", - "familyName": "Roodman" - } - ], - "contributor": [ - { - "@type": "Person", - "givenName": "Achim", - "familyName": "Zeileis" - }, - { - "@type": "Person", - "givenName": "Nathaniel", - "familyName": "Graham" - }, - { - "@type": "Person", - "givenName": "Susanne", - "familyName": "Koell" - }, - { - "@type": "Person", - "givenName": "Laurent", - "familyName": "Berge" - }, - { - "@type": "Person", - "givenName": "Sebastian", - "familyName": "Krantz" - } - ], - "maintainer": [ - { - "@type": "Person", - "givenName": "Alexander", - "familyName": "Fischer", - "email": "alexander-fischer1801@t-online.de" - } - ], - "softwareSuggestions": [ - { - "@type": "SoftwareApplication", - "identifier": "bench", - "name": "bench", - "provider": { - "@id": "https://cran.r-project.org", - "@type": "Organization", - "name": "Comprehensive R Archive Network (CRAN)", - "url": "https://cran.r-project.org" - }, - "sameAs": "https://CRAN.R-project.org/package=bench" - }, - { - "@type": "SoftwareApplication", - "identifier": "broom", - "name": "broom", - "provider": { - "@id": "https://cran.r-project.org", - "@type": "Organization", - "name": "Comprehensive R Archive Network (CRAN)", - "url": "https://cran.r-project.org" - }, - "sameAs": "https://CRAN.R-project.org/package=broom" - }, - { - "@type": "SoftwareApplication", - "identifier": "clubSandwich", - "name": "clubSandwich", - "provider": { - "@id": "https://cran.r-project.org", - "@type": "Organization", - "name": "Comprehensive R Archive Network (CRAN)", - "url": "https://cran.r-project.org" - }, - "sameAs": "https://CRAN.R-project.org/package=clubSandwich" - }, - { - "@type": "SoftwareApplication", - "identifier": "covr", - "name": "covr", - "provider": { - "@id": "https://cran.r-project.org", - "@type": "Organization", - "name": "Comprehensive R Archive Network (CRAN)", - "url": "https://cran.r-project.org" - }, - "sameAs": "https://CRAN.R-project.org/package=covr" - }, - { - "@type": "SoftwareApplication", - "identifier": "data.table", - "name": "data.table", - "provider": { - "@id": "https://cran.r-project.org", - "@type": "Organization", - "name": "Comprehensive R Archive Network (CRAN)", - "url": "https://cran.r-project.org" - }, - "sameAs": "https://CRAN.R-project.org/package=data.table" - }, - { - "@type": "SoftwareApplication", - "identifier": "fabricatr", - "name": "fabricatr", - "provider": { - "@id": "https://cran.r-project.org", - "@type": "Organization", - "name": "Comprehensive R Archive Network (CRAN)", - "url": "https://cran.r-project.org" - }, - "sameAs": "https://CRAN.R-project.org/package=fabricatr" - }, - { - "@type": "SoftwareApplication", - "identifier": "fixest", - "name": "fixest", - "provider": { - "@id": "https://cran.r-project.org", - "@type": "Organization", - "name": "Comprehensive R Archive Network (CRAN)", - "url": "https://cran.r-project.org" - }, - "sameAs": "https://CRAN.R-project.org/package=fixest" - }, - { - "@type": "SoftwareApplication", - "identifier": "gt", - "name": "gt", - "provider": { - "@id": "https://cran.r-project.org", - "@type": "Organization", - "name": "Comprehensive R Archive Network (CRAN)", - "url": "https://cran.r-project.org" - }, - "sameAs": "https://CRAN.R-project.org/package=gt" - }, - { - "@type": "SoftwareApplication", - "identifier": "ivreg", - "name": "ivreg", - "provider": { - "@id": "https://cran.r-project.org", - "@type": "Organization", - "name": "Comprehensive R Archive Network (CRAN)", - "url": "https://cran.r-project.org" - }, - "sameAs": "https://CRAN.R-project.org/package=ivreg" - }, - { - "@type": "SoftwareApplication", - "identifier": "knitr", - "name": "knitr", - "provider": { - "@id": "https://cran.r-project.org", - "@type": "Organization", - "name": "Comprehensive R Archive Network (CRAN)", - "url": "https://cran.r-project.org" - }, - "sameAs": "https://CRAN.R-project.org/package=knitr" - }, - { - "@type": "SoftwareApplication", - "identifier": "lfe", - "name": "lfe", - "provider": { - "@id": "https://cran.r-project.org", - "@type": "Organization", - "name": "Comprehensive R Archive Network (CRAN)", - "url": "https://cran.r-project.org" - }, - "sameAs": "https://CRAN.R-project.org/package=lfe" - }, - { - "@type": "SoftwareApplication", - "identifier": "lmtest", - "name": "lmtest", - "provider": { - "@id": "https://cran.r-project.org", - "@type": "Organization", - "name": "Comprehensive R Archive Network (CRAN)", - "url": "https://cran.r-project.org" - }, - "sameAs": "https://CRAN.R-project.org/package=lmtest" - }, - { - "@type": "SoftwareApplication", - "identifier": "modelsummary", - "name": "modelsummary", - "provider": { - "@id": "https://cran.r-project.org", - "@type": "Organization", - "name": "Comprehensive R Archive Network (CRAN)", - "url": "https://cran.r-project.org" - }, - "sameAs": "https://CRAN.R-project.org/package=modelsummary" - }, - { - "@type": "SoftwareApplication", - "identifier": "rmarkdown", - "name": "rmarkdown", - "provider": { - "@id": "https://cran.r-project.org", - "@type": "Organization", - "name": "Comprehensive R Archive Network (CRAN)", - "url": "https://cran.r-project.org" - }, - "sameAs": "https://CRAN.R-project.org/package=rmarkdown" - }, - { - "@type": "SoftwareApplication", - "identifier": "sandwich", - "name": "sandwich", - "provider": { - "@id": "https://cran.r-project.org", - "@type": "Organization", - "name": "Comprehensive R Archive Network (CRAN)", - "url": "https://cran.r-project.org" - }, - "sameAs": "https://CRAN.R-project.org/package=sandwich" - }, - { - "@type": "SoftwareApplication", - "identifier": "testthat", - "name": "testthat", - "version": ">= 3.0.0", - "provider": { - "@id": "https://cran.r-project.org", - "@type": "Organization", - "name": "Comprehensive R Archive Network (CRAN)", - "url": "https://cran.r-project.org" - }, - "sameAs": "https://CRAN.R-project.org/package=testthat" - }, - { - "@type": "SoftwareApplication", - "identifier": "tibble", - "name": "tibble", - "provider": { - "@id": "https://cran.r-project.org", - "@type": "Organization", - "name": "Comprehensive R Archive Network (CRAN)", - "url": "https://cran.r-project.org" - }, - "sameAs": "https://CRAN.R-project.org/package=tibble" - }, - { - "@type": "SoftwareApplication", - "identifier": "MASS", - "name": "MASS", - "provider": { - "@id": "https://cran.r-project.org", - "@type": "Organization", - "name": "Comprehensive R Archive Network (CRAN)", - "url": "https://cran.r-project.org" - }, - "sameAs": "https://CRAN.R-project.org/package=MASS" - } - ], - "softwareRequirements": { - "1": { - "@type": "SoftwareApplication", - "identifier": "collapse", - "name": "collapse", - "provider": { - "@id": "https://cran.r-project.org", - "@type": "Organization", - "name": "Comprehensive R Archive Network (CRAN)", - "url": "https://cran.r-project.org" - }, - "sameAs": "https://CRAN.R-project.org/package=collapse" - }, - "2": { - "@type": "SoftwareApplication", - "identifier": "dqrng", - "name": "dqrng", - "provider": { - "@id": "https://cran.r-project.org", - "@type": "Organization", - "name": "Comprehensive R Archive Network (CRAN)", - "url": "https://cran.r-project.org" - }, - "sameAs": "https://CRAN.R-project.org/package=dqrng" - }, - "3": { - "@type": "SoftwareApplication", - "identifier": "dreamerr", - "name": "dreamerr", - "provider": { - "@id": "https://cran.r-project.org", - "@type": "Organization", - "name": "Comprehensive R Archive Network (CRAN)", - "url": "https://cran.r-project.org" - }, - "sameAs": "https://CRAN.R-project.org/package=dreamerr" - }, - "4": { - "@type": "SoftwareApplication", - "identifier": "Formula", - "name": "Formula", - "provider": { - "@id": "https://cran.r-project.org", - "@type": "Organization", - "name": "Comprehensive R Archive Network (CRAN)", - "url": "https://cran.r-project.org" - }, - "sameAs": "https://CRAN.R-project.org/package=Formula" - }, - "5": { - "@type": "SoftwareApplication", - "identifier": "generics", - "name": "generics", - "provider": { - "@id": "https://cran.r-project.org", - "@type": "Organization", - "name": "Comprehensive R Archive Network (CRAN)", - "url": "https://cran.r-project.org" - }, - "sameAs": "https://CRAN.R-project.org/package=generics" - }, - "6": { - "@type": "SoftwareApplication", - "identifier": "gtools", - "name": "gtools", - "provider": { - "@id": "https://cran.r-project.org", - "@type": "Organization", - "name": "Comprehensive R Archive Network (CRAN)", - "url": "https://cran.r-project.org" - }, - "sameAs": "https://CRAN.R-project.org/package=gtools" - }, - "7": { - "@type": "SoftwareApplication", - "identifier": "JuliaConnectoR", - "name": "JuliaConnectoR", - "provider": { - "@id": "https://cran.r-project.org", - "@type": "Organization", - "name": "Comprehensive R Archive Network (CRAN)", - "url": "https://cran.r-project.org" - }, - "sameAs": "https://CRAN.R-project.org/package=JuliaConnectoR" - }, - "8": { - "@type": "SoftwareApplication", - "identifier": "Matrix", - "name": "Matrix", - "provider": { - "@id": "https://cran.r-project.org", - "@type": "Organization", - "name": "Comprehensive R Archive Network (CRAN)", - "url": "https://cran.r-project.org" - }, - "sameAs": "https://CRAN.R-project.org/package=Matrix" - }, - "9": { - "@type": "SoftwareApplication", - "identifier": "Rcpp", - "name": "Rcpp", - "provider": { - "@id": "https://cran.r-project.org", - "@type": "Organization", - "name": "Comprehensive R Archive Network (CRAN)", - "url": "https://cran.r-project.org" - }, - "sameAs": "https://CRAN.R-project.org/package=Rcpp" - }, - "10": { - "@type": "SoftwareApplication", - "identifier": "rlang", - "name": "rlang", - "provider": { - "@id": "https://cran.r-project.org", - "@type": "Organization", - "name": "Comprehensive R Archive Network (CRAN)", - "url": "https://cran.r-project.org" - }, - "sameAs": "https://CRAN.R-project.org/package=rlang" - }, - "11": { - "@type": "SoftwareApplication", - "identifier": "summclust", - "name": "summclust", - "provider": { - "@id": "https://cran.r-project.org", - "@type": "Organization", - "name": "Comprehensive R Archive Network (CRAN)", - "url": "https://cran.r-project.org" - }, - "sameAs": "https://CRAN.R-project.org/package=summclust" - }, - "SystemRequirements": "Version Requirements to run the wild bootstrap through\n Julia - Julia (>= 1.8), WildBootTests.jl (>=0.9.8). Julia is\n downloadable via the official Julia website\n (https://julialang.org/downloads/), WildBootTests.jl via Julia's\n package manager (https://docs.julialang.org/en/v1/stdlib/Pkg/) or its\n github repository (https://github.com/droodman/WildBootTests.jl)" - }, - "fileSize": "3870.729KB", - "citation": [ - { - "@type": "CreativeWork", - "datePublished": "2021", - "author": [ - { - "@type": "Person", - "givenName": "Alexander", - "familyName": "Fischer" - }, - { - "@type": "Person", - "givenName": "David", - "familyName": "Roodman" - } - ], - "name": "fwildclusterboot: Fast Wild Cluster Bootstrap Inference for Linear Regression Models (Version 0.14.2)", - "url": "https://cran.r-project.org/package=fwildclusterboot" - } - ], - "relatedLink": ["https://s3alfisc.github.io/fwildclusterboot/", "https://CRAN.R-project.org/package=fwildclusterboot"], - "releaseNotes": "https://github.com/s3alfisc/fwildclusterboot/blob/master/NEWS.md", - "readme": "https://github.com/s3alfisc/fwildclusterboot/blob/master/README.md", - "contIntegration": ["https://github.com/s3alfisc/fwildclusterboot/actions", "https://app.codecov.io/gh/s3alfisc/fwildclusterboot?branch=master"], - "developmentStatus": "https://lifecycle.r-lib.org/articles/stages.html", - "review": { - "@type": "Review", - "url": "https://github.com/ropensci/software-review/issues/546", - "provider": "https://ropensci.org" - }, - "keywords": ["clustered-standard-errors", "wild-bootstrap", "linear-regression-models", "wild-cluster-bootstrap"] -} diff --git a/cran-comments.md b/cran-comments.md index 1fcbcd20..9a073bce 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -1,3 +1,43 @@ +## Resubmission of 0.15 + +- I turned off a test that ran for too long. I had accidentally turned it on + +## Submission of 0.15 + +I have tested the package on: +- rhub +- win devel +- github actions + +and received the following notes: + +* checking for non-standard things in the check directory ... NOTE +Found the following files/directories: + ''NULL'' + +* checking for detritus in the temp directory ... NOTE + 'lastMiKTeXException' +Found the following files/directories: + +* Found the following (possibly) invalid URLs: + URL: https://journals.sagepub.com/doi/pdf/10.1177/1536867X19830877 + From: inst/doc/Literature.html + Status: 403 + Message: Forbidden + URL: https://onlinelibrary.wiley.com/doi/abs/10.1002/jrsm.1554 + From: inst/doc/Literature.html + Status: 403 + Message: Forbidden + URL: https://www.tandfonline.com/doi/abs/10.1198/jbes.2009.07221 + From: inst/doc/Literature.html + inst/doc/fwildclusterboot.html + README.md + Status: 403 + Message: Forbidden + +I have checked all links - all are valid. + + ## Submission of 0.13 I have tested the package on: diff --git a/man/boottest.Rd b/man/boottest.Rd index 42f50ace..51d37f42 100644 --- a/man/boottest.Rd +++ b/man/boottest.Rd @@ -22,7 +22,7 @@ the fast wild bootstrap algorithm developed in Roodman et al., 2019. \details{ Technical Details For technical details, either take a look at the references below, or check -out the \href{wild_bootstrap.html}{wild (cluster) bootstrap vignette}. +out the \href{https://s3alfisc.github.io/fwildclusterboot/articles/wild_bootstrap.html}{wild (cluster) bootstrap vignette}. } \section{Setting Seeds}{ diff --git a/man/setBoottest_nthreads.Rd b/man/setBoottest_nthreads.Rd new file mode 100644 index 00000000..6f3bf98b --- /dev/null +++ b/man/setBoottest_nthreads.Rd @@ -0,0 +1,19 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/utils.R +\name{setBoottest_nthreads} +\alias{setBoottest_nthreads} +\title{Set the number of threads for use with open mp via options +By default, only one thread is used} +\usage{ +setBoottest_nthreads(nthreads) +} +\arguments{ +\item{nthreads}{Integer. Number of threads to be used} +} +\value{ +No return value +} +\description{ +Set the number of threads for use with open mp via options +By default, only one thread is used +} diff --git a/tests/testthat/test-convergence.R b/tests/testthat/test-convergence.R index a5917b1d..5d66d331 100644 --- a/tests/testthat/test-convergence.R +++ b/tests/testthat/test-convergence.R @@ -1,3 +1,6 @@ +fwildclusterboot::setBoottest_nthreads(1) + + test_that("algorithm performance test", { diff --git a/tests/testthat/test-error_warning.R b/tests/testthat/test-error_warning.R index e53bcaf6..3e008f22 100644 --- a/tests/testthat/test-error_warning.R +++ b/tests/testthat/test-error_warning.R @@ -1,3 +1,6 @@ +fwildclusterboot::setBoottest_nthreads(1) + + test_that("errors and warnings q = 1", { diff --git a/tests/testthat/test-full-enumeration.R b/tests/testthat/test-full-enumeration.R index 6f87f8ee..7c47fe4b 100644 --- a/tests/testthat/test-full-enumeration.R +++ b/tests/testthat/test-full-enumeration.R @@ -1,3 +1,6 @@ +fwildclusterboot::setBoottest_nthreads(1) + + test_that("test full enumeration cases: r and r-lean", { #' @srrstats {G5.4} **Correctness tests** *to test that statistical algorithms diff --git a/tests/testthat/test-global_vars.R b/tests/testthat/test-global_vars.R index 11bfc871..79744af9 100644 --- a/tests/testthat/test-global_vars.R +++ b/tests/testthat/test-global_vars.R @@ -1,3 +1,6 @@ +fwildclusterboot::setBoottest_nthreads(1) + + test_that("global engine", { skip_on_cran() skip_if_not( @@ -66,61 +69,61 @@ test_that("global engine", { -# test_that("global nthreads", { -# skip_on_ci() -# skip_on_cran() -# -# data(voters) -# lm_fit <- -# lm(proposition_vote ~ treatment + ideology1 + log_income + Q1_immigration, -# data = voters) -# -# boot1 <- -# boottest(lm_fit, -# param = "treatment", -# B = 999, -# clustid = "group_id1") -# boot2 <- -# boottest( -# lm_fit, -# param = "treatment", -# B = 999, -# clustid = "group_id1", -# nthreads = 4 -# ) -# boot3 <- -# boottest( -# lm_fit, -# param = "treatment", -# B = 999, -# clustid = "group_id1", -# nthreads = 0.5 -# ) -# -# expect_equal(boot1$nthreads, 1) -# expect_equal(boot2$nthreads, 4) -# expect_equal(boot3$nthreads, 4) -# -# setBoottest_nthreads(4) -# expect_equal(getOption("boottest_nthreads"), 4) -# expect_equal(getBoottest_nthreads(), 4) -# # switch back to "R" as global variable at end of function -# on.exit(setBoottest_nthreads(), add = TRUE) -# -# boot3 <- -# boottest(lm_fit, -# param = "treatment", -# B = 999, -# clustid = "group_id1") -# boot4 <- -# boottest( -# lm_fit, -# param = "treatment", -# B = 999, -# clustid = "group_id1", -# nthreads = 2 -# ) -# -# expect_equal(boot3$nthreads, 4) -# expect_equal(boot4$nthreads, 2) -# }) +test_that("global nthreads", { + skip_on_ci() + skip_on_cran() + + data(voters) + lm_fit <- + lm(proposition_vote ~ treatment + ideology1 + log_income + Q1_immigration, + data = voters) + + boot1 <- + boottest(lm_fit, + param = "treatment", + B = 999, + clustid = "group_id1") + boot2 <- + boottest( + lm_fit, + param = "treatment", + B = 999, + clustid = "group_id1", + nthreads = 4 + ) + boot3 <- + boottest( + lm_fit, + param = "treatment", + B = 999, + clustid = "group_id1", + nthreads = 0.5 + ) + + expect_equal(boot1$nthreads, 1) + expect_equal(boot2$nthreads, 4) + expect_equal(boot3$nthreads, 4) + + setBoottest_nthreads(4) + expect_equal(getOption("boottest_nthreads"), 4) + expect_equal(getBoottest_nthreads(), 4) + # switch back to "R" as global variable at end of function + on.exit(setBoottest_nthreads(), add = TRUE) + + boot3 <- + boottest(lm_fit, + param = "treatment", + B = 999, + clustid = "group_id1") + boot4 <- + boottest( + lm_fit, + param = "treatment", + B = 999, + clustid = "group_id1", + nthreads = 2 + ) + + expect_equal(boot3$nthreads, 4) + expect_equal(boot4$nthreads, 2) +}) diff --git a/tests/testthat/test-method_equivalence.R b/tests/testthat/test-method_equivalence.R index 072a772b..a614c600 100644 --- a/tests/testthat/test-method_equivalence.R +++ b/tests/testthat/test-method_equivalence.R @@ -1,3 +1,6 @@ +fwildclusterboot::setBoottest_nthreads(1) + + test_that("Do different, but equivalent ways to specify linear models lead to equivalent results?", { skip_on_cran() @@ -179,6 +182,7 @@ test_that("Do different, but equivalent ways to specify # one-way clustering create_models <- function(clustid) { + R1 <- clubSandwich::constrain_zero(2:3, coefs = coef(lm_fit)) R2 <- matrix(c(1, 0, 0, 1, 0, 0), 2, 3) R3 <- clubSandwich::constrain_zero(1:2, coefs = coef(felm_fit8)) @@ -187,8 +191,8 @@ test_that("Do different, but equivalent ways to specify for (engine in c("R", "WildBootTests.jl")) { # boottest() cat("boottest()", "\n") - set.seed(8965) - dqrng::dqset.seed(765) + set.seed(89651) + dqrng::dqset.seed(74465) assign(paste0("boot_lm_", engine), suppressWarnings( @@ -206,8 +210,8 @@ test_that("Do different, but equivalent ways to specify envir = .GlobalEnv ) - set.seed(8965) - dqrng::dqset.seed(765) + set.seed(89651) + dqrng::dqset.seed(74465) assign(paste0("boot_fixest1_", engine), suppressWarnings( @@ -225,8 +229,8 @@ test_that("Do different, but equivalent ways to specify envir = .GlobalEnv ) - set.seed(8965) - dqrng::dqset.seed(765) + set.seed(89651) + dqrng::dqset.seed(74465) assign(paste0("boot_fixest2_", engine), suppressWarnings( @@ -244,8 +248,8 @@ test_that("Do different, but equivalent ways to specify envir = .GlobalEnv ) - set.seed(8965) - dqrng::dqset.seed(765) + set.seed(89651) + dqrng::dqset.seed(74465) assign(paste0("boot_fixest3_", engine), suppressWarnings( @@ -263,8 +267,8 @@ test_that("Do different, but equivalent ways to specify envir = .GlobalEnv ) - set.seed(8965) - dqrng::dqset.seed(765) + set.seed(89651) + dqrng::dqset.seed(74465) assign(paste0("boot_fixest4_", engine), suppressWarnings( @@ -282,8 +286,8 @@ test_that("Do different, but equivalent ways to specify envir = .GlobalEnv ) - set.seed(8965) - dqrng::dqset.seed(765) + set.seed(89651) + dqrng::dqset.seed(74465) assign(paste0("boot_fixest5_", engine), suppressWarnings( @@ -301,8 +305,8 @@ test_that("Do different, but equivalent ways to specify envir = .GlobalEnv ) - set.seed(8965) - dqrng::dqset.seed(765) + set.seed(89651) + dqrng::dqset.seed(74465) assign(paste0("boot_fixest6_", engine), suppressWarnings( @@ -320,8 +324,8 @@ test_that("Do different, but equivalent ways to specify envir = .GlobalEnv ) - set.seed(8965) - dqrng::dqset.seed(765) + set.seed(89651) + dqrng::dqset.seed(74465) assign(paste0("boot_fixest7_", engine), suppressWarnings( @@ -339,8 +343,8 @@ test_that("Do different, but equivalent ways to specify envir = .GlobalEnv ) - set.seed(8965) - dqrng::dqset.seed(765) + set.seed(89651) + dqrng::dqset.seed(74465) assign(paste0("boot_fixest8_", engine), suppressWarnings( @@ -358,8 +362,8 @@ test_that("Do different, but equivalent ways to specify envir = .GlobalEnv ) - set.seed(8965) - dqrng::dqset.seed(765) + set.seed(89651) + dqrng::dqset.seed(74465) assign(paste0("boot_fixest9_", engine), suppressWarnings( @@ -377,8 +381,8 @@ test_that("Do different, but equivalent ways to specify envir = .GlobalEnv ) - set.seed(8965) - dqrng::dqset.seed(765) + set.seed(89651) + dqrng::dqset.seed(74465) assign(paste0("boot_fixest10_", engine), suppressWarnings( @@ -396,8 +400,8 @@ test_that("Do different, but equivalent ways to specify envir = .GlobalEnv ) - set.seed(8965) - dqrng::dqset.seed(765) + set.seed(89651) + dqrng::dqset.seed(74465) assign(paste0("boot_fixest11_", engine), suppressWarnings( @@ -415,8 +419,8 @@ test_that("Do different, but equivalent ways to specify envir = .GlobalEnv ) - set.seed(8965) - dqrng::dqset.seed(765) + set.seed(89651) + dqrng::dqset.seed(74465) assign(paste0("boot_fixest12_", engine), suppressWarnings( @@ -434,8 +438,8 @@ test_that("Do different, but equivalent ways to specify envir = .GlobalEnv ) - set.seed(8965) - dqrng::dqset.seed(765) + set.seed(89651) + dqrng::dqset.seed(74465) assign(paste0("boot_fixest13_", engine), suppressWarnings( @@ -453,8 +457,8 @@ test_that("Do different, but equivalent ways to specify envir = .GlobalEnv ) - set.seed(8965) - dqrng::dqset.seed(765) + set.seed(89651) + dqrng::dqset.seed(74465) assign(paste0("boot_fixest6fe_", engine), suppressWarnings( @@ -473,8 +477,8 @@ test_that("Do different, but equivalent ways to specify envir = .GlobalEnv ) - set.seed(8965) - dqrng::dqset.seed(765) + set.seed(89651) + dqrng::dqset.seed(74465) assign(paste0("boot_fixest7fe_", engine), suppressWarnings( @@ -493,8 +497,8 @@ test_that("Do different, but equivalent ways to specify envir = .GlobalEnv ) - set.seed(8965) - dqrng::dqset.seed(765) + set.seed(89651) + dqrng::dqset.seed(74465) assign(paste0("boot_fixest8fe_", engine), suppressWarnings( @@ -513,8 +517,8 @@ test_that("Do different, but equivalent ways to specify envir = .GlobalEnv ) - set.seed(8965) - dqrng::dqset.seed(765) + set.seed(89651) + dqrng::dqset.seed(74465) assign(paste0("boot_fixest9fe_", engine), suppressWarnings( @@ -533,8 +537,8 @@ test_that("Do different, but equivalent ways to specify envir = .GlobalEnv ) - set.seed(8965) - dqrng::dqset.seed(765) + set.seed(89651) + dqrng::dqset.seed(74465) assign(paste0("boot_fixest10fe_", engine), suppressWarnings( @@ -553,8 +557,8 @@ test_that("Do different, but equivalent ways to specify envir = .GlobalEnv ) - set.seed(8965) - dqrng::dqset.seed(765) + set.seed(89651) + dqrng::dqset.seed(74465) # why suddenly fe = Q2_defense? Should give the same models assign(paste0("boot_fixest11fe_", engine), @@ -574,8 +578,8 @@ test_that("Do different, but equivalent ways to specify envir = .GlobalEnv ) - set.seed(8965) - dqrng::dqset.seed(765) + set.seed(89651) + dqrng::dqset.seed(74465) assign(paste0("boot_fixest12fe_", engine), suppressWarnings( @@ -594,8 +598,8 @@ test_that("Do different, but equivalent ways to specify envir = .GlobalEnv ) - set.seed(8965) - dqrng::dqset.seed(765) + set.seed(89651) + dqrng::dqset.seed(74465) assign(paste0("boot_fixest13fe_", engine), suppressWarnings( @@ -614,8 +618,8 @@ test_that("Do different, but equivalent ways to specify envir = .GlobalEnv ) - set.seed(8965) - dqrng::dqset.seed(765) + set.seed(89651) + dqrng::dqset.seed(74465) assign(paste0("boot_felm1_", engine), suppressWarnings( @@ -633,8 +637,8 @@ test_that("Do different, but equivalent ways to specify envir = .GlobalEnv ) - set.seed(8965) - dqrng::dqset.seed(765) + set.seed(89651) + dqrng::dqset.seed(74465) assign(paste0("boot_felm2_", engine), suppressWarnings( @@ -652,8 +656,8 @@ test_that("Do different, but equivalent ways to specify envir = .GlobalEnv ) - set.seed(8965) - dqrng::dqset.seed(765) + set.seed(89651) + dqrng::dqset.seed(74465) assign(paste0("boot_felm3_", engine), suppressWarnings( @@ -671,8 +675,8 @@ test_that("Do different, but equivalent ways to specify envir = .GlobalEnv ) - set.seed(8965) - dqrng::dqset.seed(765) + set.seed(89651) + dqrng::dqset.seed(74465) assign(paste0("boot_felm4_", engine), suppressWarnings( @@ -690,8 +694,8 @@ test_that("Do different, but equivalent ways to specify envir = .GlobalEnv ) - set.seed(8965) - dqrng::dqset.seed(765) + set.seed(89651) + dqrng::dqset.seed(74465) assign(paste0("boot_felm5_", engine), suppressWarnings( @@ -709,8 +713,8 @@ test_that("Do different, but equivalent ways to specify envir = .GlobalEnv ) - set.seed(8965) - dqrng::dqset.seed(765) + set.seed(89651) + dqrng::dqset.seed(74465) assign(paste0("boot_felm6_", engine), suppressWarnings( @@ -728,8 +732,8 @@ test_that("Do different, but equivalent ways to specify envir = .GlobalEnv ) - set.seed(8965) - dqrng::dqset.seed(765) + set.seed(89651) + dqrng::dqset.seed(74465) assign(paste0("boot_felm4fe_", engine), suppressWarnings( @@ -748,8 +752,8 @@ test_that("Do different, but equivalent ways to specify envir = .GlobalEnv ) - set.seed(8965) - dqrng::dqset.seed(765) + set.seed(89651) + dqrng::dqset.seed(74465) assign(paste0("boot_felm5fe_", engine), suppressWarnings( @@ -768,8 +772,8 @@ test_that("Do different, but equivalent ways to specify envir = .GlobalEnv ) - set.seed(8965) - dqrng::dqset.seed(765) + set.seed(89651) + dqrng::dqset.seed(74465) assign(paste0("boot_felm6fe_", engine), suppressWarnings( @@ -788,8 +792,8 @@ test_that("Do different, but equivalent ways to specify envir = .GlobalEnv ) - set.seed(8965) - dqrng::dqset.seed(765) + set.seed(89651) + dqrng::dqset.seed(74465) assign(paste0("boot_felm7fe_", engine), suppressWarnings( @@ -1378,7 +1382,12 @@ test_that("Do different, but equivalent ways to specify test_that("clustid can be fe", { + print_results <- FALSE + + set.seed(2351) + dqrng::dqset.seed(2351) + data1 <<- fwildclusterboot:::create_data( @@ -1406,7 +1415,10 @@ test_that("clustid can be fe", { group_id1, data = data1 ) - + + set.seed(2351) + dqrng::dqset.seed(2351) + fit1 <- boottest( feols_fit1, @@ -1417,6 +1429,9 @@ test_that("clustid can be fe", { ssc = boot_ssc(adj = FALSE, cluster.adj = FALSE) ) + set.seed(2351) + dqrng::dqset.seed(2351) + fit2 <- boottest( felm_fit1, diff --git a/tests/testthat/test-new-bootstrap-variants.R b/tests/testthat/test-new-bootstrap-variants.R index 8f4bfec5..d03f191b 100644 --- a/tests/testthat/test-new-bootstrap-variants.R +++ b/tests/testthat/test-new-bootstrap-variants.R @@ -1,3 +1,6 @@ +fwildclusterboot::setBoottest_nthreads(1) + + test_that("test r-fnw vs r-, stochastic", { skip_on_cran() diff --git a/tests/testthat/test-r-heteroskedastic.R b/tests/testthat/test-r-heteroskedastic.R index 00dcb33d..0ec897e8 100644 --- a/tests/testthat/test-r-heteroskedastic.R +++ b/tests/testthat/test-r-heteroskedastic.R @@ -1,3 +1,6 @@ +fwildclusterboot::setBoottest_nthreads(1) + + test_that("test heteroskedastic boottest against fixest", { diff --git a/tests/testthat/test-r-vs-julia.R b/tests/testthat/test-r-vs-julia.R index d7ba1f4b..79bca5e7 100644 --- a/tests/testthat/test-r-vs-julia.R +++ b/tests/testthat/test-r-vs-julia.R @@ -1,3 +1,5 @@ +fwildclusterboot::setBoottest_nthreads(1) + test_that("test r against Julia I: stochastic tests", { #' @srrstats {G5.4} **Correctness tests** *to test that statistical algorithms diff --git a/tests/testthat/test-seed.R b/tests/testthat/test-seed.R index 5991b760..f138b7c7 100644 --- a/tests/testthat/test-seed.R +++ b/tests/testthat/test-seed.R @@ -1,3 +1,6 @@ +fwildclusterboot::setBoottest_nthreads(1) + + test_that("seed works for OLS", { skip_on_cran() skip_if_not( diff --git a/tests/testthat/test-tstat_equivalence.R b/tests/testthat/test-tstat_equivalence.R index 9aaecf12..541079bb 100644 --- a/tests/testthat/test-tstat_equivalence.R +++ b/tests/testthat/test-tstat_equivalence.R @@ -1,3 +1,7 @@ +fwildclusterboot::setBoottest_nthreads(1) + + + test_that("t-stat equivalence OLS - R and R-lean, against fixest", { #' @srrstats {G5.4} **Correctness tests** *to test that statistical algorithms diff --git a/tests/testthat/test-uncategorized.R b/tests/testthat/test-uncategorized.R index b7c764aa..708d323a 100644 --- a/tests/testthat/test-uncategorized.R +++ b/tests/testthat/test-uncategorized.R @@ -1,3 +1,6 @@ +fwildclusterboot::setBoottest_nthreads(1) + + test_that("uncategorized tests", { skip_on_cran() skip_if_not( diff --git a/tests/testthat/test_fixest_sugar.R b/tests/testthat/test_fixest_sugar.R index 7ad48139..96da1103 100644 --- a/tests/testthat/test_fixest_sugar.R +++ b/tests/testthat/test_fixest_sugar.R @@ -1,3 +1,6 @@ +fwildclusterboot::setBoottest_nthreads(1) + + test_that("test fixest formula sugar", { voters <- fwildclusterboot:::create_data( N = 10000, diff --git a/tests/testthat/test_multicollinearity.R b/tests/testthat/test_multicollinearity.R index 4bff848f..324a282c 100644 --- a/tests/testthat/test_multicollinearity.R +++ b/tests/testthat/test_multicollinearity.R @@ -1,3 +1,6 @@ +fwildclusterboot::setBoottest_nthreads(1) + + test_that("test multicollinearity", { N <- 1000 X1 <- rnorm(N) diff --git a/tests/testthat/test_samplers.R b/tests/testthat/test_samplers.R index 040a3891..0877a8dd 100644 --- a/tests/testthat/test_samplers.R +++ b/tests/testthat/test_samplers.R @@ -1,3 +1,5 @@ +fwildclusterboot::setBoottest_nthreads(1) + test_that("test sampling", { data1 <<- fwildclusterboot:::create_data( diff --git a/tests/testthat/test_sunab.R b/tests/testthat/test_sunab.R index ba29ecbf..ac521438 100644 --- a/tests/testthat/test_sunab.R +++ b/tests/testthat/test_sunab.R @@ -1,11 +1,11 @@ -test_that("test sunab", { - +fwildclusterboot::setBoottest_nthreads(1) - skip_if_not( - find_proglang("julia"), - message = "skip test as julia installation not found." - ) +test_that("test sunab", { + + + skip_on_cran() + library(fixest) # Simple DiD example base_stagg <- fixest::base_stagg @@ -68,6 +68,9 @@ test_that("test sunab", { fixest_pval <- as.vector(pvalue(summary(res_sunab, agg = TRUE))) fixest_teststat <- as.vector(tstat(summary(res_sunab, agg = TRUE))) + set.seed(8795) + dqrng::dqset.seed(2136) + boot_year <- boot_aggregate( res_sunab, @@ -108,6 +111,10 @@ test_that("test sunab hetero", { skip_on_cran() skip_on_ci() + set.seed(8795) + dqrng::dqset.seed(2136) + + library(fixest) # Simple DiD example base_stagg <- fixest::base_stagg diff --git a/tests/testthat/test_tidy.R b/tests/testthat/test_tidy.R index 31538219..86165a7e 100644 --- a/tests/testthat/test_tidy.R +++ b/tests/testthat/test_tidy.R @@ -1,3 +1,5 @@ +fwildclusterboot::setBoottest_nthreads(1) + test_that("test tidiers with q = 1", { skip_on_cran() skip_if_not( diff --git a/vignettes/Literature.Rmd b/vignettes/Literature.Rmd index 5191b887..8857a506 100644 --- a/vignettes/Literature.Rmd +++ b/vignettes/Literature.Rmd @@ -33,7 +33,7 @@ Methods for Cluster-Robust Inference (Journal of Applied Econometrics), 2023](ht + [Davidson & MacKinnon - Wild bootstrap tests for IV regression (Journal of Economic and Business Statistics), 2010](https://www.tandfonline.com/doi/abs/10.1198/jbes.2009.07221) Introduces the WRE bootstrap / wild cluster bootstrap for instrumental variables regression. -+ [Cameron, Gelbach & Miller - Bootstrap-based improvements for inference with clustered errors (Review of Economics and Statistics)](https://www.nber.org/system/files/working_papers/t0344/t0344.pdf) The paper that started the literature on wild cluster bootstrap inference. Simulation evidence that the wild cluster bootstrap works remarkably well when there are only few clusters. ++ [Cameron, Gelbach & Miller - Bootstrap-based improvements for inference with clustered errors (Review of Economics and Statistics)](https://www.econstor.eu/bitstream/10419/31404/1/514886757.pdf) The paper that started the literature on wild cluster bootstrap inference. Simulation evidence that the wild cluster bootstrap works remarkably well when there are only few clusters. + [Flachaire - Bootstrapping heteroskedastic regression models: wild bootstrap vs. pairs bootstrap (Computational Statistics & Data Analysis), 2005](https://shs.hal.science/file/index/docid/175910/filename/Flachaire_03a.pdf) Provides simulation evidence of the performance of *heteroskedastic* wild bootstrap procedures. @@ -41,7 +41,7 @@ Methods for Cluster-Robust Inference (Journal of Applied Econometrics), 2023](ht + [Joshi, Megha, James E. Pustejovsky, and S. Natasha Beretvas - "Cluster wild bootstrapping to handle dependent effect sizes in meta‐analysis with a small number of studies." (Research Synthesis Methods), 2022](https://onlinelibrary.wiley.com/doi/abs/10.1002/jrsm.1554) Nice simulations on the empirical performance of the wild cluster bootstrap for tests of multiple joint hypotheses. -+ [Kline & Santos - A Score Based Approach to Wild Bootstrap Inference (Journal of Econometric Methods), 2012](https://www.nber.org/system/files/working_papers/w16127/w16127.pdf) Introduces a score based wild bootstrap for non-linear regression models. ++ [Kline & Santos - A Score Based Approach to Wild Bootstrap Inference (Journal of Econometric Methods), 2012](https://eml.berkeley.edu/~pkline/papers/ScoreFinal_web.pdf) Introduces a score based wild bootstrap for non-linear regression models. ## Links, blogposts, etc