I am running a fixed-effect model using xtivreg2 in stata, where my panel variable is firms and my time variable is years. It is survey data that tracks firms over year through different iterations of the survey. Let me begin by saying that in my original dataset, the panel variable idpanel is always repeated at least once. That is, there are no firms which are observed for only one year. There are also no missing idpanel. The command is:

xtivreg2 depvar var1 var2 (var3= instrument), fe ro

What happens is that xtivreg2 gives me a warning:

Warning - singleton groups detected. 4552 observation(s) not used.

Such that the number of observations for the first-stage regression is 17489, and the same for the second stage. Therefore this command is dropping observations during the first-stage regression part. So I proceeded to replicate the first stage regression using:

xtreg var3 var1 var2 instrument, fe ro

And the number of observations, 26,370, is significantly higher than its first-stage regression counterpart in xtivreg2. The coefficients are also different.

After some exploring, I've noticed that the reason is because in the first-stage regression of xtivreg2 the command drops observations whenever there is a missing in any of the covariates or the dependent variables. Afterwards it recalculates the panel, and of course it finds now some firms for which the observation has been dropped in a given year because of the aforementioned missings, but not in other years, hence it has become a singleton.

My question therefore is: why. From a theoretical point of view, a replication of the first-stage regression using xtreg should present the same results (coefficients) as the first-stage calculated within xtivreg2, no?. In my case it doesn't. Thank you all in advance.