# Re: st: st : how to treat endogeneous variables with NLSUR

 From "Abdel Rahmen El Lahga" To statalist@hsphsun2.harvard.edu Subject Re: st: st : how to treat endogeneous variables with NLSUR Date Wed, 7 Nov 2007 15:49:09 +0100

```I'm not a user of Stata 10 but i have a few remarks on this:
1) It looks like an estimation of AIDS (Almost ideal demand system)
and i don't understand    why you try to instrument log price 2.
2) the theorie bhind the specification of price and it's square lnp2
and lnp2^2 as a regressors in  item 2 of your system is not clear.
3) Usually what is instrumented is the total expenditure (lnexp) price
are supposed exogenous
4) I guess that NLSUR can not treat endogeneity problem
5) conditional on your price index lnP you have a linear system of
equation and you could estimate it by reg3
6) Finally if a suppose that your specification is correct you still
have a linear system just generate P2=lnp2^2 and replace it on your
system
HTH
AbdelRahmen

2007/11/7, orozco@toulouse.inra.fr <orozco@toulouse.inra.fr>:
> Hi,
>
> I already posted my question last week, but I didn't receive any ideas of
> answer. Maybe I was unclear, so I try again to explain.
>
> I just would like to know if it is possible to treat the problem of endogeneity
> estimating a system of equations (more especially using NLSUR).
> In fact, I suppose some variables to be endogeneous but I don't know how to
> specify my equations of instrumentation (differently from my main system) and
> test the validity of my variables (like with the overid command after ivreg2).
>
>  I tried to write a little program estimating the following system of 2
>  equations :
>  w1 = a1 + a11 lnp1 + b1 lnp2 + b11 * (lnexp - lnP)
>  w2 = a2 + a12 lnp2 + b2 lnp2^2 + b12 (lnexp - lnP)
>  with lnP = a1 lnp1 + a2 lnp2 + a11*a12 + lnp1*lnp1 + lnp1*lnp2 + lnp2*lnp1 +
>  lnp2*lnp2
>
>  and I want to instrument the variable lnp2 that I suppose to be endogeneous
>  (with 2 instruments : expfd and p1 for example).
>  But it doesnt work and I have no idea how to correctly specify it.
>
>  Thank you for trying to help me.
>
>  valérie
>
>
>  capture program drop nlsurtest
>
>  program nlsurtest
>      version 10
>      syntax varlist(min=5 max=7) if, at(name)
>      tokenize `varlist'
>      args w1 w2 lnp1 lnp2 lnm expfd p1
>
>      tempname a1 a2  a11 a12
>      scalar `a1' = `at'[1,1]
>      scalar `a2' = `at'[1,2]
>      scalar `a11' = `at'[1,3]
>      scalar `a12' = `at'[1,4]
>
>      tempname b1 b2 b11 b12
>      scalar `b1' = `at'[1,5]
>      scalar `b2' = `at'[1,6]
>      scalar `b11' = `at'[1,7]
>      scalar `b12' = `b11'
>
>      tempname t1 t2
>      scalar `t1' = `at'[1,8]
>      scalar `t2' = `at'[1,9]
>
>      quietly {
>          tempvar toto
>          gen double `toto' = `a1' * `lnp1' + `a2' * `lnp2' + `a11' * `a12'
>          forvalues i =  1/2 {
>              forvalues j=1/2 {
>                  replace `toto' = `toto' + `lnp`i'' * `lnp`j''
>              }
>          }
>          replace `w1' = `a1' + `a11' * `lnp1' + `b1'*`lnp2' + `b11' * (`lnm' -
>  `toto')
>          replace `w2' = `a2' + `a12' * `lnp2' + `b2'*`lnp2'^2 + `b12' * (`lnm'
>  -
>  `toto')
>          replace `lnp2' = `t1' * `expfd' + `t2' * `p1'  /*instrumentation
>  equation*/
>
>      }
>
>  end
>
>  use http://www.stata-press.com/data/r10/food,clear
>
>  nlsur test  @ w1 w2 lnp1 lnp2 lnexp  expfd p1 ,parameters(a1 a2 a11 a12 b1 b2
>  b11 ) neq(3) ifgnls
>
>
>
>
>
> *
> *   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/
>

--
AbdelRahmen El Lahga

*
*   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/
```