The help files for -ivreg2- and -xtivreg2- have a lot of worked
examples using real data. There is also a discussion at
http://pped.org/stata/ciwod.pdf, page 14, that has a cross-sectional
example:
use http://fmwww.bc.edu/ec-p/data/wooldridge/card, clear
loc x "exper* smsa* south mar black reg662-reg669"
reg lw educ 'x'
ivreg2 lw 'x' (educ=nearc2 nearc4), first endog(educ)
ivreg2 lw 'x' (educ=nearc2 nearc4), gmm
ivreg2 lw 'x' (educ=nearc2 nearc4), liml
but note from the earlier discussion in that paper and the papers
describing -ivreg2- that you do not run two regressions in practice,
and that all the exogenous regressors (x, presuming g is a fixed
effect and w is an error term) in your example are included in the
first stage. So, making a dataset with names that match yours:
webuse psidextract, clear
ren lw h
ren wks d
ren union x
ren occ z
and comparing the naive two-stage estimator and the correct one-step estimator:
xtreg h d x z, fe i(id)
g ok=e(sample)
xtreg d x z if ok, fe i(id)
predict dhat if ok
xtreg h dhat x if ok, fe i(id)
xtivreg h x (d=z), fe i(id)
should produce identical point estimates but very different inferences.
The last line is the "string" you requested, but I prefer
xtivreg2 h x (d=z), fe i(id) cl(id)
for reasons discussed in http://pped.org/stata/ciwod.pdf, and elsewhere.
On Nov 11, 2007 5:40 AM, <[email protected]> wrote:
> I have a panel (cross-section time-series) of firm data and I need to
> implement the following empirical model, by two-stage least squares.
>
> D_it = x_it z_it f_i u_it
> H_it = D*_it x_it g_i w_it
>
> where:
>
> 1) x_it - is a set of regressors (hopefully) significant to both
> equations
> 2) z_it - is a set of regressors that are (hopefully) significant in
> the determination of the first equation but not in the determination of
> the second.
> 3) D*_it - is the set of estimated values of D_it, from the first
> equation.
>
> My problem is that the vector "x_it" is common to both equations! So, I
> need to know how to set the model in Stata, with particular reference
> to the implementation of instruments by ivreg (and/or ivreg2). I'm a
> primer, and an example with the string to use would be of help for me.
> Many thanks for your attention.
>
> Regards,
>
> Robert
*
* 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/