# Fixed effects regression constant (intercept) using lfe::felm

3 messages
Open this post in threaded view
|

## Fixed effects regression constant (intercept) using lfe::felm

 Dear list users, When calculating a panel data regression with multiple fixed effects using the function felm() from the lfe package, no constant term (i.e. intercept) is generated in the summary results. In an old post on stackoverflow [1], someone suggested that it is possible to retrieve the value of the intercept by using the function lfe::getfe, setting the field "ef" equal to "zm2". However, I get different results when comparing the value of the intercept calculated by the function lm, with that obtained with the function lfe::getfe. Here's a reproducible example: library(lfe) # set seed for reproducible example set.seed(123) ## generate independent variables x <- rnorm(4000) x2 <- rnorm(length(x)) ## create individual and firm ids id <- factor(sample(500,length(x),replace=TRUE)) firm <- factor(sample(300,length(x),replace=TRUE)) ## generate dependent variable id.eff <- rlnorm(nlevels(id)) firm.eff <- rexp(nlevels(firm)) y <- x + 0.25*x2 + id.eff[id] + firm.eff[firm] + rnorm(length(x)) ## estimate results est <- felm(y ~ x + x2 | id + firm) est2 <- lm(y ~ x + x2 + id + firm) ## Compare estimates coef(est) #         x        x2 # 1.017696 0.246784 coef(est2)[2:3] #         x        x2 # 1.017696 0.246784 # estimate fixed effects fe_est <- getfe(est, ef = "zm2") ## Compare intercept fe_est[grepl("icpt", rownames(fe_est)), ] #          effect  obs comp # icpt.1 2.583704 4000    1 coef(est2)[1] # (Intercept) #   7.312307 I am wondering if anyone can explain this difference. Also, I would like to know if it is possible to obtain a reliable approximation of the value of the intercept estimated by lm using lfe::getfe. Best, Valerio P.s.Observe that 3 weeks ago I have posted this question on stackoverflow [2] but no one answered. [1] https://stackoverflow.com/questions/49351201/fixed-effects-regression-constant-intercept-using-lfe-felm-in-r[2] https://stackoverflow.com/questions/62497705/estimate-of-constant-term-using-r-felmlfe-package-and-differences-with-statsValerio Leone Sciabolazza, Ph.D. Department of Business and Economics University of Naples, Parthenope. ______________________________________________ [hidden email] mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.