How do I get the intercept from a fixed effects regression using fixest::feols
?
library(fixest)
feols(Sepal.Length ~ Sepal.Width | Species, iris)
#> Estimate Std. Error t value Pr(>|t|)
#> Sepal.Width 0.803561 0.071397 11.2548 0.0078023 **
For comparison, reghdfe
in Stata does show the intercept (_cons
):
ssc install reghdfe
use http://www.stata-press.com/data/r17/iris, clear
reghdfe seplen sepwid , ab(iris) cl(iris)
#> | Robust
#> seplen | Coef. Std. Err. t P>|t| [95% Conf. Interval]
#> -------------+----------------------------------------------------------------
#> sepwid | .8035609 .0713974 11.25 0.008 .4963625 1.110759
#> _cons | 3.38658 .2182857 15.51 0.004 2.447372 4.325788
The intercept can be calculated as the average of the sum of the fixed effects:
est = feols(Petal.Length ~ Sepal.Width | Species, iris)
mean(est$sumFE)
#> [1] 3.38658