I'm following the tutorial Fast Fixed-Effects Estimation: Short Introduction of the R package fixest
.
The very first example is:
library(fixest)
trade <- fixest::trade
gravity_pois <- fepois(
Euros ~ log(dist_km) | Origin + Destination + Product + Year,
trade
)
The estimated coefficient is -1.52787
with a standard error of 0.115678
I want to understand what this code is doing exactly.
I tried to replicate the results with the following code:
library(sandwich)
library(lmtest)
gravity_pois2 <- glm(
Euros ~ log(dist_km) + Origin + Destination + factor(Product) + factor(Year),
trade,
family = poisson
)
gravity_pois2_cl <- coeftest(gravity_pois2, vcov = vcovCL, cluster = ~Origin)
I obtain an estimated coefficient of approximately -1.527
with a standard error of approximately 0.1156
.
The difference between the two estimated coefficients is in the order of $10^{-14}$, and between the two standard deviations is of the order of $10^{-5}$.
My question is: from an econometric point of view, are the two codes equivalent? Is the first code just syntactic sugar for the second?
I know I can read the source code of fixest, but I don't have the skills to understand it.
Moreover, fixest purports itself to be faster, so it is probably using some algorithms to compute the values different from glm
.
Regardless of the algorithm, I would like to understand if, from an econometric point of view, the two estimates are the same.
In particular, I'm concerned about the estimate of the standard deviation, because the difference between the two is low but not too low (i.e. much higher than the difference in the estimated coefficients).