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
24 stars 4 forks source link

Boottest looking for the data in the wrong place when running inside a function #155

Open Yuval-OS opened 1 month ago

Yuval-OS commented 1 month ago

See this reproducible code: It works without a function, but when used inside a function it says it cannot find data_obj. When I define data_obj in the global directory, it works fine.

requireNamespace("fwildclusterboot") data(voters)

feols_fit <- feols(proposition_vote ~ treatment + ideology1 + log_income | Q1_immigration, data = voters) boot1 <- boottest(feols_fit, B = 9999, param = "treatment", clustid = "group_id1") summary(boot1)

boot_func <- function(data_obj) { feols_fit1 <- feols(proposition_vote ~ treatment + ideology1 + log_income | Q1_immigration, data = data_obj) boot1 <- boottest(feols_fit1, B = 9999, param = "treatment", clustid = "group_id1") return(summary(boot1)) }

boot_func(voters) data_obj <- voters boot_func(voters)