ivreghdfe
ivreghdfe copied to clipboard
estimates post: matrix has missing values r(504);
IVREGHDFE returns a "estimates post: matrix has missing values r(504);" error when a perfectly collinear variable is dropped from a model.
REGHDFE, OLD works fine when this happens.
Thanks for producing such a valuable public good!
I'm having the same issue on Stata 15.1. Did you ever find a solution? - thanks!
Just a workaround: I dropped the colinear variables from the regressions manually. I know this sounds like a solution, but it was an issue because I was looping over subsamples, so I didn't know what would be colinear before running.
Sorry I missed the initial post. I tried to reproduce this issue on my end and I can't. I would need a MWE, preferably using the "sysuse auto" dataset, in order to see what's the problem and debug it.
I got the same error after using reghdfe
and estfe
to esttab
results.
After running some model batches, I get the error when estfe model*, restore
. But others on the same dataset work fine.
I tried reconstructing the issue in the "sysuse auto" dataset by introducing a fully collinear regressor, but I cannot reproduce the error there... Here's the minimal non-working example:
* Setup
sysuse auto, clear
* Run and store regressions
gen length2 = length*2
reghdfe price weight length length2, a(turn)
estimates store model1
reghdfe price weight length length2, a(turn trunk)
estimates store model2
reghdfe price weight length length2, a(turn foreign)
estimates store model3
* Prepare estimates for -estout-
estfe model*, labels(turn "Turn FE" turn#trunk "Turn-Trunk FE")
return list
* Run estout/esttab
esttab model* , indicate("Length Controls=length" `r(indicate_fe)')
* Return stored estimates to their previous state
estfe m*, restore
Dear Sergio,
Thanks a million, and loads of sincere gratitude also from me for these great packages, and for making our lives so much easier with them!
It has been my turn to encounter this issue today. Wanted to do "eststo: ivreghdfe...,first savefirst savefprefix(abc)" and then export with "esttab", but I received the error "estimates post: matrix has missing values", which seems to stem from the fact that one of the variables is identified by Stata as being collinear with the FE.
So I was also wondering whether in the end there has been any solution or workaround?
In the meantime, I tried to run the same regression using "reghdfe..., ... old", which instead of dropping the collinear variable keeps it in the equation (thereby producing an implausibly high coefficient). I then get the first-stages estimates I have been after.
Thank you so much in advance for any guidance you could provide, and best, Maria
Just a workaround: I dropped the colinear variables from the regressions manually. I know this sounds like a solution, but it was an issue because I was looping over subsamples, so I didn't know what would be colinear before running.
This worked for me as well.