Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support cluster argument to feols() #10

Open
SebKrantz opened this issue Dec 12, 2023 · 3 comments
Open

Support cluster argument to feols() #10

SebKrantz opened this issue Dec 12, 2023 · 3 comments

Comments

@SebKrantz
Copy link

options(fastverse.styling = FALSE)
library(fastverse)
#> -- Attaching packages --------------------------------------- fastverse 0.3.2 --
#> v data.table 1.14.8     v kit        0.0.13
#> v magrittr   2.0.3      v collapse   2.0.7
fastverse_extend(fixest, wildrwolf)
#> -- Attaching extension packages ----------------------------- fastverse 0.3.2 --
#> Warning: package 'fixest' was built under R version 4.3.1
#> v fixest    0.11.2     v wildrwolf 0.6.1
#> -- Conflicts ------------------------------------------ fastverse_conflicts() --
#> x fixest::fdim() masks collapse::fdim()
models = feols(c(vs, am) ~ mpg | cyl, mtcars, cluster = "carb")
rwolf(models = models, param = "mpg", B = 9999)
#>   |                                                                              |                                                                      |   0%
#> Error in formula.character(clustid): invalid formula "carb": not a call

models = feols(c(vs, am) ~ mpg | cyl, mtcars, cluster = ~carb)
rwolf(models = models, param = "mpg", B = 9999)
#>   |                                                                              |                                                                      |   0%
#> Warning: Please note that the seeding behavior for random number generation for
#> `boottest()` has changed with `fwildclusterboot` version 0.13.
#> 
#> It will no longer be possible to exactly reproduce results produced by versions
#> lower than 0.13.
#> 
#> If your prior results were produced under sufficiently many bootstrap
#> iterations, none of your conclusions will change.  For more details about this
#> change, please read the notes in
#> [news.md](https://cran.r-project.org/web/packages/fwildclusterboot/news/news.html).
#> This warning is displayed once per session.
#> Warning: There are only 64 unique draws from the rademacher distribution for 6 bootstrap
#> clusters. Therefore, B = 64 with full enumeration. Consider using webb weights
#> instead. Further, note that under full enumeration and with B = 64 bootstrap
#> draws, only 2^(#clusters - 1) = 32 distinct t-statistics and p-values can be
#> computed. For a more thorough discussion, see Webb `Reworking wild bootstrap
#> based inference for clustered errors` (2013).
#>   |                                                                              |===================================                                   |  50%
#> Warning: There are only 64 unique draws from the rademacher distribution for 6 bootstrap
#> clusters. Therefore, B = 64 with full enumeration. Consider using webb weights
#> instead. Further, note that under full enumeration and with B = 64 bootstrap
#> draws, only 2^(#clusters - 1) = 32 distinct t-statistics and p-values can be
#> computed. For a more thorough discussion, see Webb `Reworking wild bootstrap
#> based inference for clustered errors` (2013).
#>   |                                                                              |======================================================================| 100%
#>   model     Estimate Std. Error    t value    Pr(>|t|) RW Pr(>|t|)
#> 1     1 -0.006000719 0.01009511 -0.5944186   0.5781065   0.9692308
#> 2     2   0.04767382 0.01039968   4.584163 0.005924984   0.2000000

models = feols(c(vs, am) ~ mpg | cyl, mtcars, cluster = as.character(mtcars$carb))
rwolf(models = models, param = "mpg", B = 9999)
#>   |                                                                              |                                                                      |   0%
#> Error in terms.formula(formula, data = data): invalid model formula in ExtractVars

Created on 2023-12-12 with reprex v2.0.2

@s3alfisc
Copy link
Owner

Thanks for reporting. I have plenty of time off between now and the new year and will make sure to take a look!

s3alfisc added a commit that referenced this issue Jan 14, 2024
`wildrwolf 0.7.0`: fix #10'
@s3alfisc
Copy link
Owner

s3alfisc commented Jan 14, 2024

Some of this should be fixed now and available on r-universe in the next hour. CRAN might take me a little longer 😅

models = feols(c(vs, am) ~ mpg | cyl, mtcars, cluster = as.character(mtcars$carb))
rwolf(models = models, param = "mpg", B = 9999)

This one I have not fixed, as boottest() does not allow for vector-valued input. I'll work towards a nicer error message in
this case.

@s3alfisc s3alfisc reopened this Jan 14, 2024
@SebKrantz SebKrantz reopened this Jan 15, 2024
@SebKrantz
Copy link
Author

Thanks! I see you want to keep it open, otherwise I would have closed it now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants