Skip to content

Commit

Permalink
add engine_btype check; switch to R-lean whenever engine = "WildBootT…
Browse files Browse the repository at this point in the history
…ests.jl" but the hetero bootstrap is run (prior, no clear error message) #135
  • Loading branch information
s3alfisc committed Sep 13, 2023
1 parent 3614479 commit a75865d
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 16 deletions.
18 changes: 14 additions & 4 deletions R/boottest_felm.R
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,12 @@ boottest.felm <- function(object,
}
}
}

check_engine_btype(
engine = engine,
bootstrap_type = bootstrap_type
)


if (!is.null(beta0)) {
rlang::abort(
Expand Down Expand Up @@ -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
}
} else {
heteroskedastic <- FALSE
}

check_bootstrap_types(
param = param,
bootstrap_type = bootstrap_type
Expand Down
19 changes: 14 additions & 5 deletions R/boottest_fixest.R
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,12 @@ boottest.fixest <- function(object,
}
}
}


check_engine_btype(
engine = engine,
bootstrap_type = bootstrap_type
)

if (!is.null(beta0)) {
rlang::abort(
c(
Expand Down Expand Up @@ -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
}
} else {
heteroskedastic <- FALSE
}

check_bootstrap_types(
param = param,
bootstrap_type = bootstrap_type
Expand Down
14 changes: 9 additions & 5 deletions R/boottest_lm.R
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ boottest.lm <- function(object,
engine = engine,
bootstrap_type = bootstrap_type
)

if (!is.null(beta0)) {
rlang::abort(
c(
Expand Down Expand Up @@ -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
}
} else {
heteroskedastic <- FALSE
}

check_bootstrap_types(
param = param,
bootstrap_type = bootstrap_type
Expand Down
4 changes: 2 additions & 2 deletions R/onLoad.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
.onAttach <-
function(libname, pkgname) {

packageStartupMessage("Note that with version 0.15, rademacher weights are")
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 bootsrap inferences under a given seed. If this is a ")
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.")

Expand Down

0 comments on commit a75865d

Please sign in to comment.