Skip to content

Commit

Permalink
Merge pull request #114 from s3alfisc/dev
Browse files Browse the repository at this point in the history
v0.14
  • Loading branch information
s3alfisc authored Jul 8, 2023
2 parents 7d33427 + 77f0243 commit add82ae
Show file tree
Hide file tree
Showing 60 changed files with 3,151 additions and 1,568 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ jobs:

# install WildBootTests.jl
- name: install WildBootTests.jl
run: julia -e 'using Pkg; Pkg.add(["WildBootTests", "StableRNGs"])'
run: julia -e 'using Pkg; Pkg.add(["StableRNGs"]); Pkg.add(Pkg.PackageSpec(;name="WildBootTests", version="0.9.9"))'
# use shell bash to ensure consistent behavior across OS
shell: bash

Expand Down
20 changes: 15 additions & 5 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
Package: fwildclusterboot
Title: Fast Wild Cluster Bootstrap Inference for Linear Models
Version: 0.13.2
Version: 0.14.0
Authors@R: c(
person("Alexander", "Fischer", , "[email protected]", role = c("aut", "cre")),
person("David", "Roodman", role = "aut"),
person("Megha", "Joshi",
role = "rev",
comment = "Megha reviewed the package (v. 0.13) for ropensci
, see <https://github.com/ropensci/software-review/issues/546>"
),
person("Eunseop", "Kim",
role = "rev",
comment = "Eunseop reviewed the package (v. 0.13) for ropensci
, see <https://github.com/ropensci/software-review/issues/546>"
),
person("Achim", "Zeileis", role = "ctb",
comment = "Author of included sandwich fragments"),
person("Nathaniel", "Graham", role = "ctb",
Expand Down Expand Up @@ -42,7 +52,6 @@ Imports:
generics,
gtools,
JuliaConnectoR,
MASS,
Matrix,
Rcpp,
rlang,
Expand All @@ -64,7 +73,8 @@ Suggests:
rmarkdown,
sandwich,
testthat (>= 3.0.0),
tibble
tibble,
MASS
LinkingTo:
Rcpp,
RcppArmadillo,
Expand All @@ -77,9 +87,9 @@ Language: en-US
LazyData: true
Roxygen: list(markdown = TRUE, roclets = c ("namespace", "rd",
"srr::srr_stats_roclet"))
RoxygenNote: 7.2.1
RoxygenNote: 7.2.3
SystemRequirements: Version Requirements to run the wild bootstrap through
Julia - Julia (>= 1.8), WildBootTests.jl (>=0.9). Julia is
Julia - Julia (>= 1.8), WildBootTests.jl (>=0.9.8). Julia is
downloadable via the official Julia website
(https://julialang.org/downloads/), WildBootTests.jl via Julia's
package manager (https://docs.julialang.org/en/v1/stdlib/Pkg/) or its
Expand Down
10 changes: 7 additions & 3 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ S3method(mboottest,lm)
S3method(nobs,boottest)
S3method(nobs,mboottest)
S3method(plot,boottest)
S3method(print,boottest)
S3method(print,mboottest)
S3method(pval,boottest)
S3method(pval,mboottest)
S3method(summary,boottest)
Expand All @@ -34,12 +32,18 @@ export(teststat)
export(tidy)
importFrom(JuliaConnectoR,juliaEval)
importFrom(JuliaConnectoR,juliaImport)
importFrom(MASS,ginv)
importFrom(Matrix,Diagonal)
importFrom(Matrix,Matrix)
importFrom(Matrix,crossprod)
importFrom(Matrix,sparse.model.matrix)
importFrom(Matrix,t)
importFrom(Matrix,tcrossprod)
importFrom(Rcpp,evalCpp)
importFrom(collapse,GRP)
importFrom(collapse,fmean)
importFrom(collapse,fsum)
importFrom(collapse,qF)
importFrom(collapse,qtab)
importFrom(dqrng,dqsample)
importFrom(dqrng,dqset.seed)
importFrom(dreamerr,check_arg)
Expand Down
36 changes: 35 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,37 @@
# fwildclusterboot 0.14

## Breaking Changes

- the `print.boottest()` and `print.mboottest()` method have been deprecated, as both did not have a distinct use case.
- Bugfix: `boottest()` should never have run with `fixest::feols()` and
varying slopes syntax via `var1[var2]`. Unfortunately it did for the heteroskedastic bootstrap - it's a bug. I am very sorry if you are affected by this! This version adds an error message for this case.

## Performance

Version 0.14 ...

- sparsifies the "fast and reliable" bootstraps - bootstrap types 31, 33, 13 (which leads to good speed gains for problems with high dimensional fixed effects)
- allows to project out cluster fixed effects when running the "fast and reliable" algorithms "11" and "31"
- computes the generalized inverse `pinv` via rcpp eigen instead of `MASS::ginv()` whenever `Matrix::solve()` fails
- unlocks parallelization (nthreads was internally set to 1 for some reason)


## rOpenSci Review feedback

- update docs:
- add a vignette on wild bootstrap concepts (wild bootstrap 101)
- better explanation of plot method in docs and vignette
- some guidelines on how to turn messages and warnings off
- reorganization of ropensci ssr tags into code
- it is now possible to interrupt rcpp loops


## Misc

- throws a clear error message when the subcluster bootstrap is tried for the fast and reliable algos (currently not supported)
- bumps the required `WildBootTests.jl` version to `0.9.7`


# fwildclusterboot 0.13

## Potentially Breaking Changes:
Expand Down Expand Up @@ -308,7 +342,7 @@ I have spent some time to clean up `fwildclusterboot's` internals, which should
+ Bug fix: for one-sided hypotheses for the WRU bootstrap (if impose_null = FALSE), the returned p-values were incorrect - they were reported as 'p', but should have been '1-p'. E.g. if the reported p-values was reported as 0.4, it should have been reported as 0.6.
+ A new function argument `ssc` gives more control over the small sample adjustments made within `boottest()`. It closely mirrors the `ssc` argument in `fixest`. The only difference is that `fwildclusterboot::boot_ssc()'s` `fixef.K` argument currently has only one option, `'none'`, which means that the fixed effect parameters are discarded when calculating the number of estimated parameters k.
The default argument of `boot_ssc()` are `adj = TRUE, fixef.K = "none", cluster.adj = TRUE` and `cluster.df = "conventional"`. In fixest, the `cluster.df` argument is `"min"` by default.
Prior to v 0.6, by default, no small sample adjustments regarding the sample size N and the number of estimated parameters k were applied. The changes in v0.6 may slightly affect the output of `boottest()`. For exact reproducibility of previous results, set `adj = FALSE`. Setting `adj = TRUE` will not affect p-values and confidence intervals for *oneway clustering*, but the internally calculated t-stat, which is divided by $\sqrt{(N-k)/(N-1)}$. For *twoway* clustering, it might affect the number and order of invalid bootstrapped t-statistics (due to non-positive definite covariance matrices) and, through this channel, affect bootstrapped inferential parameters.
Prior to v 0.6, by default, no small sample adjustments regarding the sample size N and the number of estimated parameters k were applied. The changes in v0.6 may slightly affect the output of `boottest()`. For exact reproducibility of previous results, set `adj = FALSE`. Setting `adj = TRUE` will not affect p-values and confidence intervals for *oneway clustering*, but the internally calculated t-stat, which is divided by sqrt(N-k)/(N-1). For *twoway* clustering, it might affect the number and order of invalid bootstrapped t-statistics (due to non-positive definite covariance matrices) and, through this channel, affect bootstrapped inferential parameters.

+ Testing: unit tests are now run on [github actions](https://github.com/s3alfisc/fwildclusterboot/actions/workflows/R-CMD-check.yaml) against [wildboottestjlr](https://github.com/s3alfisc/wildboottestjlr), which is a [JuliaConnectoR](https://github.com/stefan-m-lenz/JuliaConnectoR) based wrapper around [WildBootTests.jl](https://github.com/droodman/WildBootTests.jl), a Julia implementation of the fast wild cluster bootstrap algorithm.
+ Additionally, minor speed tweaks.
Expand Down
22 changes: 22 additions & 0 deletions R/RcppExports.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,24 @@ boot_algo3_crv3 <- function(B, G, k, v, scores_mat, scores_boot, inv_tXX_tXgXg,
.Call('_fwildclusterboot_boot_algo3_crv3', PACKAGE = 'fwildclusterboot', B, G, k, v, scores_mat, scores_boot, inv_tXX_tXgXg, cores, R, delta_b_star)
}

convertSparse <- function(mat) {
.Call('_fwildclusterboot_convertSparse', PACKAGE = 'fwildclusterboot', mat)
}

compute_H <- function(G, R, tXXinv, tXgXg, scores_list, cores) {
.Call('_fwildclusterboot_compute_H', PACKAGE = 'fwildclusterboot', G, R, tXXinv, tXgXg, scores_list, cores)
}

pinv <- function(X) {
.Call('_fwildclusterboot_pinv', PACKAGE = 'fwildclusterboot', X)
}

#' Moore-Penrose Pseudo Inverses via Eigen
#' @param A a matrix
#' @return A matrix. Pseudo-Inverse of A.
#' @noRd
NULL

#' Matrix Multiplication via Eigen
#' @param A A matrix.
#' @param B A matrix.
Expand All @@ -19,6 +37,10 @@ eigenMapMatMult <- function(A, B, nthreads) {
.Call('_fwildclusterboot_eigenMapMatMult', PACKAGE = 'fwildclusterboot', A, B, nthreads)
}

eigen_pinv <- function(A) {
.Call('_fwildclusterboot_eigen_pinv', PACKAGE = 'fwildclusterboot', A)
}

#' Get maximum number of threads on hardware for open mp support
#' @noRd
cpp_get_nb_threads <- function() {
Expand Down
Loading

0 comments on commit add82ae

Please sign in to comment.