How does one obtain the intercept ('constant') when using the felm
function (of the lfe
package) for panel data with fixed effects?
Reproducible example:
library(lfe)
set.seed(42)
x <- rnorm(100000)
f1 <- sample(10000, length(x), replace=TRUE)
f2 <- sample(10000, length(x), replace=TRUE)
y <- 2.13*x + cos(f1) + log(f2+1) + rnorm(length(x), sd=0.5)
est <- felm(y ~ x + G(f1) + G(f2))
summary(est)
This yields:
Call:
felm(formula = y ~ x + G(f1) + G(f2))
Residuals
Min 1Q Median 3Q Max
-1.9531308 -0.3018539 -0.0003573 0.3007738 2.2052754
Coefficients:
Estimate Std. Error t value Pr(>|t|)
x 2.130889 0.001768 1205 <2e-16 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 0.5013 on 80000 degrees of freedom
Multiple R-squared: 0.9683 Adjusted R-squared: 0.9603
F-statistic: 122.1 on 19999 and 80000 DF, p-value: < 2.2e-16
Notice there is no intercept...
I noticed the following in the 'lfe' package documentation (https://journal.r-project.org/archive/2013/RJ-2013-031/RJ-2013-031.pdf):
"The careful reader has noticed that the behaviour of summary() on a ’felm’ object with respect to degrees of freedom and R 2 is the same as that of on an ’lm’ object when including an intercept. There is no explicit intercept in the result of felm(), but the factor structure includes one implicitly"
Thank you.