UPDATE: Sunday, March 4
Yesterday, I received the following message from David Drukker, the Executive Director of Econometrics at Stata:
"The xtreg-fe command in Stata produces consistent point estimates and
standard errors for all the model parameters. There is a typo on page 27 of
https://www.stata.com/manuals/xtxtreg.pdf . The formula for bar(bar(y))
should be the grand mean instead of the average of the panel-level means.
William Gould explicitly derived the grand mean as the term to add back in
to recover the intercept term. See equations (3), (4), and (5) in
Thank you for calling our attention to this typo. We will update the
manual as quickly as possible."
Excellent! So the problem is in the manual, not in the code. Rest assured, you can keep using xtreg, fe.
Posted on March 2:
Versions tested: v.14.1 and v.15.1. Outcome: Both failed.
I believe the problem is with each and every installation: the RCE, desktop and laptop installations.
Several days ago I tried to replicate results from -xtreg, fe- by re-implementing the command using the formula shown in Stata 15's manual entry for -xtreg, fe-. I failed. The issue was that in unbalanced panels -xtreg, fe-'s estimate and my estimate of the intercept and its standard error differed. I checked my calculations, and since they looked fine, I contacted Stata. Tech support at Stata were responsive at first but once I provided them with a quick math illustration of the issue, it took a couple of emails, one unanswered phone call and several days of waiting to receive the following:
"I would like to point out that we take this kind of claims very seriously and we need to have more than one of our technical staff to review the potential problem. We will be contacting you as soon as we get a complete evaluation on your report."
Seems Stata acknowledges that there may be a problem. I hope they address it soon.
RECOMMENDATION TO RESEARCHERS: If you are using -xtreg, fe- with unbalanced panel data, STOP using it NOW unless you are ONLY interested in estimates other than the intercept. Do not perform any post-estimation computations that use the estimates of the intercept and its standard error as they will be incorrect. You may want to use a different command (-regress- with dummies for panelvar) or write your own implementation of -xtreg, fe-.
To illustrate the issue (and also help users with writing their own implementation), I have attached a zip file containing a detailed explanation of the problem and a replication example. Parts of the code in the replication example were provided by StataCorp, parts are mine. You can use this code to test whether your installation is subject to the issue.
Author: Simo Goshev