s3alfisc / fwildclusterboot

Fast Wild Cluster Bootstrap Inference for Regression Models / OLS in R. Additionally, R port to WildBootTests.jl via the JuliaConnectoR.
https://s3alfisc.github.io/fwildclusterboot/
GNU General Public License v3.0
23 stars 4 forks source link

Singularity Issue #89

Closed jcha1997 closed 1 year ago

jcha1997 commented 1 year ago

Great to see the package back on CRAN!

I attempted to run some code that worked in an earlier version, but am running into a matrix solution error:

Error in solve.default(R %*% A %*% t(R)) : Lapack routine dgesv: system is exactly singular: U[1,1] = 0

A toy example of my code is:

library(fixest)
library(fwildclusterboot)

model <- feols(y ~ x1 + x2 | fe1 + fe2, data = df, cluster = "clusterid")

boottest(model, clustid = "clusterid", param = "pres_median", fe = "fe1", B = 9999)
s3alfisc commented 1 year ago

Hi @jcha1997 - that's definitely not good. Sorry for the inconvenience! I hope that I will find time later today to look at this in more detail.

Some things that might help me debugging:

I took a quick look at tests that I am running, they seem to behave fine (though I am running version 0.12.3 locally):

library(fwildclusterboot)
library(fixest)

df <- 
fwildclusterboot:::create_data(
  N = 1000, 
  N_G1 = 20, 
  N_G2 = 20, 
  icc1 = 0.5, 
  icc2  = 0.5, 
  numb_fe1 = 10, 
  numb_fe2 = 10, 
  seed = 3
)

fit <- feols(
  proposition_vote ~ treatment + income | Q1_immigration + Q2_defense, 
  cluster = ~group_id1, 
  data = df
)

wcb1 <- boottest(fit, param = ~treatment, clustid = ~group_id1, B = 999, seed = 12)
wcb2 <- boottest(fit, param = ~treatment, clustid = ~group_id1, B = 999, fe = "Q1_immigration", seed = 12)

tidy(wcb1)
# term     estimate  statistic   p.value
# 1 1*treatment = 0 -0.008866375 -0.6477245 0.5355355
# conf.low  conf.high
# 1 -0.0382505 0.01952578
tidy(wcb2)
# term     estimate  statistic   p.value
# 1 1*treatment = 0 -0.008866375 -0.6477245 0.5355355
# conf.low  conf.high
# 1 -0.0382505 0.01952578

Maybe you can reproduce the error with an example data set, if you find the time? Anyways, I promise to look at this as soon as I can!

Best, Alex

jcha1997 commented 1 year ago

Ah! I apologize - I made an error in the specification of the variable. I'll close the issue.

s3alfisc commented 1 year ago

No worries - I'm always happy to hear from people who use fwildclusterboot =) And great that it wasn't a bug after all! Was the variable not included in the fixest model? I thought I had error handling implemented for that - maybe something to improve?

jcha1997 commented 1 year ago

I had misspecified the parameter, which makes sense that I was receiving a singularity error! There was no treatment! Again, appreciate the quick help.

s3alfisc commented 1 year ago

Thanks for the feedback - good to hear that boottest() isn't producing output when it shouldn't!