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

Questions about the redundant FE reported and yhat predicted after running reghdfe #267

Open rubyyq opened 1 year ago

rubyyq commented 1 year ago

Dear Sergio,

I am writing to seek your assistance in understanding two issues that have arisen during my research involving the use of reghdfe.

Specifically, I have questions about the yhat predicted and redundant FE reported. I would be grateful if you could provide some insights on the following:

Question 1: How to interpret the yhat predicted after reghdfe?

e.g. reghdfe y x, a(id1, save) resid predict yhat, xb gen yy = y - _reghdfe_resid

I noticed that yhat does not equal to yy (y minus _reghdfe_resid). I am wondering why this is the case.

Question 2: How to interpret the redundant FE reported and the hdfe estimated after reghdfe?

e.g. There are 8 units in id1, and 16 units in id2. All units in id2 are nested with units in id1. reghdfe y x, a(id1 id2, save)

I received a report of 8 redundant FEs. Does this mean that there are 8 FEs that could not be estimated? However, all observations have values in both hdfe1 and hdfe2. Does this mean that all FEs could be estimated? And how to calculate the FEs for each unit in id1 and id2?

Thanks.

For your reference, here is the dataset I am using:

There are 8 units in id1, and 16 units in id2. All units in id2 are nested with units in id1.

y x id1 id2 2 5 1 1 3 5 1 1 4 5 1 1 1 5 1 2 3 5 1 2 4 7 2 3 5 7 2 3 6 7 2 3 7 7 2 4 4 7 2 4 6 3 3 5 2 6 3 5 3 8 3 5 4 5 3 6 4 5 3 6 7 4 4 7 5 5 4 7 4 3 4 7 3 5 4 8 5 5 4 8 2 6 5 9 4 4 5 9 5 5 5 9 6 7 5 10 7 5 5 10 3 5 6 11 4 3 6 11 5 6 6 11 8 4 6 12 6 5 6 12 6 9 7 13 5 3 7 13 4 4 7 13 5 5 7 14 7 5 7 14 7 3 8 15 4 5 8 15 7 6 8 15 4 4 8 16 7 5 8 16