sergiocorreia / reghdfe

Linear, IV and GMM Regressions With Any Number of Fixed Effects
http://scorreia.com/software/reghdfe/
MIT License
219 stars 57 forks source link

[BUG] Issue with predicting the constant term in reghdfe #203

Open fabrizioleone opened 4 years ago

fabrizioleone commented 4 years ago

Hi,

I am trying to replicate your example in the FAQs about how to get the constant term in reghdfe. However, I get a different result than you.

This is my code

sysuse auto, clear reghdfe price weight length, absorb(turn, save) resid predict double d, d sum d

and this is my output

Screenshot 2020-02-26 at 14 32 14

The mean of the constant term is very close to zero, while your result is -3473.347. However, since there are fixed effects, a zero constant term is what I expect. Am I maybe wrong?

By the way, in the second line of the code, it looks like you omitted the resid option.

Thanks in advance for having a look at this issue.

System info:

glennmagerman commented 4 years ago

Which version of reghdfe are you using? We had a similar issue, but the reference category for the FE categories changed from v3 to v4.

fabrizioleone commented 4 years ago

You are right, I am using the version 5.8.0 27dec2019. Thanks for pointing it out. I have also updated my issue.

glennmagerman commented 4 years ago

Here's our communication. Perhaps there is an update on this with the new version.

We have a small question about how the fixed effects are normalized:

About your question:

On the development version, the first fixed effects will include the constant term. Subsequent fixed effects will thus have mean zero. The reason is that there is no clear rule about where to "put the constant", so I just add it to the first FE. An alternative approach is through the -constant- option, which will report a constant and make all FEs have mean of zero. For instance: clear all cls

sysuse auto

reghdfe price weight gear, a(turn trunk, save) su __*

reghdfe price weight gear, a(turn trunk, save) constant su __*