I have a regression with many fixed effects, and, therefore, I'm using the lfe::felm function to calculate my coefficients. I'm clustering the standard error with the felm function, but I would like to test alternative standard error specifications with the sandwich package.
I'm trying to connect both of these packages, but I can not find the correct configuration for the sandwich::vcovCL function. Initially, I want both function to find the same SE.
In the following example, I run a toy regression and try to find the same SE with both functions.
# gen process
set.seed(42)
nn = 10
n1 = 3
x <- rnorm(nn)
f1 <- sample(n1, length(x), replace=TRUE)
y <- 2.13*x + cos(f1) + rnorm(length(x), sd=0.5)
# felm
est <- lfe::felm(y ~ x | f1 | 0 | f1)
resultfelm <- summary(est)
resultfelm$coefficients[2] # get cluster s.e.
# sandwich
sandwich::vcovCL(est, cluster = ~f1) %>% sqrt(.)
The standard errors are different. How can I match them?
Thanks a lot for any help