I am trying to incorporate panel data analysis to a negative binomial with fixest package. I am unsure whether I am implementing the 'panel.id' argument correctly. According to the fixest's CRAN there are to identical ways to incorporate panel data analysis.
First, I could set up a panel data set with function panel
.
Thus.
dfpanel <- panel(df1, ~id + year)
Alternatively, I could work with my original dataframe but use panel identifier argument panel.id=~id+year
.
In theory, both the first two models should calculate the same standard errors.
m1 <- fenegbin(incident~ treatdummy + poverty + rural|state,
data=dfpanel)
m2 <- fenegbin(incident~ treatdummy + poverty + rural|state,
panel.id=~id+year,
data=df1)
m3 <- fenegbin(incident~ treatdummy + poverty + rural|state,
data=df1)
Just to compare, I am running a third model with neither panel.id not panel data. If I am implementing panel analysis correct, m1 and m2 should have the same SEs
Nevertheless, I am getting that m1 and m2 have different SEs. m1 and m3 have the same SE, suggesting that I am missing something about how to implement panel data with fixest correctly.
Here is the output
> etable(m1, m2, m3)
m1 m2 m3
Dependent Var.: homicide homicide homicide
minedummy 0.3134* (0.1406) 0.3134** (0.1077) 0.3134* (0.1406)
imarg -0.3467* (0.1504) -0.3467*** (0.0600) -0.3467* (0.1504)
ruralurban 1.116*** (0.2388) 1.116*** (0.0918) 1.116*** (0.2388)
Fixed-Effects: ----------------- ------------------- -----------------
state Yes Yes Yes
_______________ _________________ ___________________ _________________
S.E.: Clustered by: state by: id by: state
Observations 30,888 30,888 30,888
What am I doing wrong?
Going off of @Parfait's comment, the SE cluster groupings are the culprit. You can make the SEs agree by explicitly specifying the
cluster
argument inm2
. See the example below:etable(m1, m2, m3, m4)
yields:Where you can see that m1, m3, and m4 all have the same standard errors. That said, I agree that this is somewhat confusing behavior and may be worth raising in the Git issues as suggested.