# Re: st: Re: instrumental variables estimation problems

 From John Antonakis To statalist@hsphsun2.harvard.edu Subject Re: st: Re: instrumental variables estimation problems Date Mon, 14 Dec 2009 14:30:59 +0100

```Hi:

```
I was wondering....would it be possible to use something similar to the below but to control for clustering for:
```
1. one dimension of clustering, with the normal -reg- , cluster(id) command
2. two dimensions of clustering, with the cgmreg, cluster(id1 id2) command

Regards,
John.

____________________________________________________

```
Prof. John Antonakis, Associate Dean Faculty of Business and Economics
```Department of Organizational Behavior
University of Lausanne
Internef #618
CH-1015 Lausanne-Dorigny
Switzerland

Tel ++41 (0)21 692-3438
Fax ++41 (0)21 692-3305

Faculty page:
http://www.hec.unil.ch/people/jantonakis

Personal page:
http://www.hec.unil.ch/jantonakis
____________________________________________________

On 08.12.2009 12:49, Kit Baum wrote:
```
```<>
-------
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/
```
```*
*   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/
```