0

I need to conduct an analysis of variance ANOVA comparing a linear model obtained through a standard OLS regression and one with heteroscedasticity robust standard errors obtained through a bootstrap cluster method.

While conducting ANOVA on the coefficients obtained through OLS is straightforward with the anova(mymodel) function, I cannot seem to find a way to do it on the bootstrap clustered coefficients obtained through the boottestfunction of the fwildclusterbootpackage. The following doesn't seem to work.

# "lm" is my linear model
lm_coefnames <- c("treatment", "var1", "var2", "Intercept")
set.seed(2020)

boot_lm <- matrix(NA, length(lm_coefnames), 4)
for (i in 1:length(lm_coefnames)){
  
  boot_lm[i, ] <- as.numeric(summary(boottest(lm, clustid = "cluster_variable", 
                           param = lm1_coefnames[i], B = 9999))[1, c(2,4:6)])
}

anova(summary(boot_lm))

Any ideas?

orpr0
  • 15
  • 2
  • Hi @opr0, sorry for replying so late, just seeing this now. What is the exact error message you get? In principle, I'd say that your approach should work. – A.Fischer Feb 11 '23 at 19:00

1 Answers1

0

just tried this, and I cannot replicate the error that you have gotten with version 0.12.3 of the package.

library(fwildclusterboot)
data(voters)

data(voters)
lm_fit <- lm(proposition_vote ~ treatment + ideology1 + log_income +
               Q1_immigration,
             data = voters
)
params <- c("treatment", "ideology1", "log_income")

for(x in params){
  
  boottest(lm_fit,
           B = 9999,
           param = x,
           clustid = "group_id1"
  )
  
}

for(x in seq_along(params)){
  
  boottest(lm_fit,
           B = 9999,
           param = params[x],
           clustid = "group_id1"
  )
  
}
A.Fischer
  • 596
  • 5
  • 11