## create covariates
x <- rnorm(100)
x2 <- rnorm(length(x))
## individual and firm
id <- factor(sample(10,length(x),replace=TRUE))
firm <- factor(sample(3,length(x),replace=TRUE))
## effects for them
id.eff <- rnorm(nlevels(id))
firm.eff <- rnorm(nlevels(firm))
## left hand side
y <- x + 0.5*x2 + id.eff[id] + firm.eff[firm] + rnorm(length(x))
## estimate and print result
est <- felm(y ~ x+x2,fl=list(id=id,firm=firm),data=data.frame(y,x,x2))
print(est)
print(getfe(est))
Run the code above in your browser using DataLab