From b2f62c5712701a8567ecb582a4f14806285581bf Mon Sep 17 00:00:00 2001 From: Alexander Fischer Date: Sun, 14 Jan 2024 11:50:37 +0100 Subject: [PATCH] fix #10' --- DESCRIPTION | 4 ++-- NEWS.md | 6 ++++++ R/rwolf.R | 6 +++++- tests/testthat/test_misc.R | 20 ++++++++++++++++++++ 4 files changed, 33 insertions(+), 3 deletions(-) create mode 100644 tests/testthat/test_misc.R diff --git a/DESCRIPTION b/DESCRIPTION index 4f63715..ac26944 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -2,7 +2,7 @@ Package: wildrwolf Type: Package Title: Fast Computation of Romano-Wolf Corrected p-Values for Linear Regression Models -Version: 0.6.1 +Version: 0.7.0 Authors@R: c( person(given = "Alexander", @@ -19,7 +19,7 @@ Description: Fast Routines to Compute Romano-Wolf corrected p-Values License: GPL (>= 3) Encoding: UTF-8 LazyData: true -RoxygenNote: 7.2.1 +RoxygenNote: 7.2.3 Imports: fixest, fwildclusterboot, diff --git a/NEWS.md b/NEWS.md index aa6bd8e..0a329c5 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,9 @@ +# wildrwolf 0.7.0 + +* Fixes a bug when the cluster in `feols()` was specified as character. + See [#10](https://github.com/s3alfisc/wildrwolf/issues/10) for details. + Thanks to [@SebKrantz](https://github.com/SebKrantz) for reporting! + # wildrwolf 0.6.1 * Hot-Fix release to address ATLAS test failures. Failing diff --git a/R/rwolf.R b/R/rwolf.R index a45dc37..e7b4902 100644 --- a/R/rwolf.R +++ b/R/rwolf.R @@ -200,7 +200,11 @@ rwolf <- function( ) if(!is.null(clustid)){ - boottest_quote$clustid <- formula(clustid) + if(is.character(clustid)){ + boottest_quote$clustid <- formula(paste0("~", clustid)) + } else { + boottest_quote$clustid <- formula(clustid) + } } if(!is.null(bootstrap_type)){ diff --git a/tests/testthat/test_misc.R b/tests/testthat/test_misc.R new file mode 100644 index 0000000..18c5b10 --- /dev/null +++ b/tests/testthat/test_misc.R @@ -0,0 +1,20 @@ +test_that("test cluster input", { + + # test that wildrwolf accepts formulas and characters + # as fixest cluster input + + library(fixest) + library(wildrwolf) + + dqrng::dqset.seed(123) + models1 = feols(c(vs, am) ~ mpg | cyl, mtcars, cluster = "carb") + rwolf1 = rwolf(models = models, param = "mpg", B = 9999) + + dqrng::dqset.seed(123) + models2 = feols(c(vs, am) ~ mpg | cyl, mtcars, cluster = ~carb) + rwolf2 = rwolf(models = models, param = "mpg", B = 9999) + + expect_equal(rwolf1, rwolf2) + + +})