# Re: st: Residuals in ivreg and xtivreg

 From "Austin Nichols" To statalist@hsphsun2.harvard.edu Subject Re: st: Residuals in ivreg and xtivreg Date Wed, 14 May 2008 08:02:37 -0400

```These are very different models, so the residuals should not be the
same.  See e.g.
http://www.stata.com/support/faqs/stat/panel.html
and -findit xtserial- and read the references therein, for a start.

Also read the entry on -xtabond- and
http://www.cgdev.org/content/publications/detail/11619
to see why the commands as written are likely to produce flawed estimates.

On Wed, May 14, 2008 at 7:13 AM, Paulo Regis
> Dear all,
>
> Comparing ivreg and xtivreg, I found different residuals (and the same
> issue arises with reg and xtreg). Imagine you have a panel of
> countries. The output of ivreg and xtivreg are equivalent if they are
> expressed as
>
> xi: ivreg y (l.y = l.x1 l.x2) x1 x2 i.country,
> predict r, resid
>
> xtivreg y (l.y = l.x1 l.x2) x1 x2 , i(country) fe
> predict xb, xb
> gen r=y-xb
>
> where I have a dependent and 2 independent variables, and a fixed
> effect for each country. However, there is a large difference in the
> residuals. Why is this? I need the residuals to check for serial
> correlation but I am not sure about the way to follow. The difference
> is quite significant since for ivreg i get positive serial correlation
> while xtivreg shows negative serial correlation.
>
> If you consider the residuals from ivreg is more convenient, I would
> appretiate your answer is clear enough so I can get them from ivreg
> since I would like to avoid the presentation of the fixed effects from
> the final regression output.
>
> Cheers
>
> Paulo
*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
```