# st: Re: instrumental variables estimation problems

 From Kit Baum To statalist@hsphsun2.harvard.edu Subject st: Re: instrumental variables estimation problems Date Tue, 8 Dec 2009 06:49:29 -0500

```<>
-------
sysuse auto,clear
ivregress 2sls price (mpg = weight length)
// these are the proper 2SLS resids: y - orig X * 2SLS beta
predict double eps, res
estat overid

// Sargan stat by hand
reg eps weight length
// compute the uncentered r^2 from this regression
predict double yhat, xb
gen double syhat2 = sum(yhat^2)
gen double seps2 = sum(eps^2)
scalar ur2 = syhat2[_N]/seps2[_N]
// Sargan: N * uncentered r^2
di e(N)*ur2
----------

On Dec 8, 2009, at 2:33 AM, Tunga wrote:

> * Regarding Question 1: In fact, my question is slightly wrong but I still
> think that it has nothing to do with the ivreg or ivreg2 command. Let me
> state my question again.
>
> The model is the following. depend = b1 + b2 endo + u. I have two
> instruments for endo and I want to test if they are exogenous. The idea of
> the test is that you regress the residuals from this model (using iv
> estimates of b1 and b2) on the instruments to see if the instruments have
> explanatory power. Hence the steps are as follows:
> Step 1. Obtain the IV estimates of b1 and b2. Here I use ivregress 2sls
> depend (endo = instone insttwo).
> Step 2. Obtain the residuals. Here the point is that I wish to get the
> residuals using these two iv estimates and the variable 'endo' and NOT the
> 'predicted endo' from the first stage of the 2SLS. Is it ok if I just use
> the command "predict resid, residuals"? Or is this command producing
> residuals using the IV estimates of b1 and b2 and the variable 'predicted
> endo'? This question is not about the updated ivreg command. It is about
> getting the correct residuals. (Note: there can be a direct, ready-made test
> for instrument exogeneity but I don't want to follow them. The test I am
> following here is intuitive and therefore I wish to follow the steps I lay
> down here.)

Kit Baum   |   Boston College Economics & DIW Berlin   |   http://ideas.repec.org/e/pba1.html
An Introduction to Stata Programming  |   http://www.stata-press.com/books/isp.html
An Introduction to Modern Econometrics Using Stata  |   http://www.stata-press.com/books/imeus.html

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
```