Hi,
Maybe my question is a trivial one. I don't know if it is possible, with NLSUR,
to estimate a system of nonlinear equations with some equations of
instrumentation (I suppose some variables to be endogeneous). If it is
possible, how can I specify it?
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/