reghdfe icon indicating copy to clipboard operation
reghdfe copied to clipboard

[BUG] Issue with predicting the constant term in reghdfe

Open fabrizioleone opened this issue 5 years ago • 3 comments

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:

  • Stata SE 15.1
  • MacOS Catalina 10.15.3
  • reghdfe version 5.8.0 27dec2019

fabrizioleone avatar Feb 26 '20 13:02 fabrizioleone

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.

glennmagerman avatar Feb 26 '20 13:02 glennmagerman

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

fabrizioleone avatar Feb 26 '20 13:02 fabrizioleone

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:

  • In the stable version, the means of both fixed effects are normalized to zero. The average of the predicted values (seller+buyer fixed effect) is then zero, whereas the sample average of the dependent variable is not.
  • In the development version (4.4.13 31jan2018), we observe that the buyer effect is mean zero whereas the seller one is not. The average of the predicted values now equals the sample average of the dependent variable.
    Can you explain how the FEs in the development version are normalized and what changed from the stable to the development branch?

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 __*

glennmagerman avatar Feb 26 '20 13:02 glennmagerman