## create covariates
x <- rnorm(5000)
x2 <- rnorm(length(x))
## create individual and firm
id <- factor(sample(1000,length(x),replace=TRUE))
firm <- factor(sample(500,length(x),replace=TRUE))
## effects
id.eff <- rlnorm(nlevels(id))
firm.eff <- rexp(nlevels(firm))
## left hand side
y <- x + 0.25*x2 + id.eff[id] + firm.eff[firm] + rnorm(length(x))
## estimate and print result
est <- felm(y ~ x+x2 + G(id)+G(firm))
summary(est)
## extract the group effects
alpha <- getfe(est)
head(alpha)
## bootstrap standard errors
head(btrap(alpha,est))
## bootstrap som differences
ef <- function(v) {
w <- c(v[2]-v[1],v[3]-v[2],v[3]-v[1])
names(w) <-c('id2-id1','id3-id2','id3-id1')
w
}
attr(ef,'noP') <- TRUE
head(btrap(alpha,est,ef=ef))Run the code above in your browser using DataLab