Hi everyone!!!
I would like to know more clearance and difference between gmm, xtabond2 and xtseqreg command. What kind of data set conditions I should use appropriate command?
I would like to know more clearance and difference between gmm, xtabond2 and xtseqreg command. What kind of data set conditions I should use appropriate command?
Code:
***GMM example**
sysuse auto
regress mpg gear_ratio turn
gmm (mpg - {b1}*gear_ratio - {b2}*turn - {b0}), instruments(gear_ratio turn)
gmm (mpg - {b1}*gear_ratio - {b2}*turn - {b0}), instruments(gear_ratio turn) derivative(/b1 = -1*gear_ratio) derivative(/b2 = -1*turn) derivative(/b0 = -1)
gmm (mpg - {xb:gear_ratio turn} - {b0}), instruments(gear_ratio turn)
gmm (mpg - {xb:gear_ratio turn} - {b0}), instruments(gear_ratio turn) derivative(/xb = -1) derivative(/b0 = -1)
ivregress 2sls mpg gear_ratio (turn = weight length headroom)
gmm (mpg - {b1}*turn - {b2}*gear_ratio - {b0}), instruments(gear_ratio weight length headroom) onestep
ivregress gmm mpg gear_ratio (turn = weight length headroom)
gmm (mpg - {b1}*turn - {b2}*gear_ratio - {b0}), instruments(gear_ratio weight length headroom) wmatrix(robust)
***xtabond2 Example***
use http://www.stata-press.com/data/r7/abdata.dta
xtabond2 n l.n l(0/1).(w k) yr1980-yr1984, gmm(l.n w k) iv(yr1980-yr1984, passthru) noleveleq small
xtabond2 n l.n l(0/1).(w k) yr1980-yr1984, gmm(l.n w k) iv(yr1980-yr1984, mz) robust twostep small h(2)
xtabond2 n l(1/2).n l(0/1).w l(0/2).(k ys) yr1980-yr1984, gmm(l.n w k) iv(yr1980-yr1984) robust twostep small
* Next two are equivalent, assuming id is the panel identifier
ivreg2 n cap (w = k ys rec) [pw=_n], cluster(id year) orthog(rec)
xtabond2 n w cap [pw=_n], iv(cap k ys, eq(level)) iv(rec, eq(level)) cluster(id year) h(1)
* Same for next two
regress n w k
xtabond2 n w k, iv(w k, eq(level)) small h(1)
* And next two, assuming xtabond updated since May 2004 with update command.
xtabond n yr*, lags(1) pre(w, lags(1,.)) pre(k, endog) robust small noconstant
xtabond2 n L.n w L.w k yr*, gmm(L.(w n k)) iv(yr*) noleveleq robust small
* And next two
xtdpd n L.n L(0/1).(w k) yr1978-yr1984, dgmm(w k n) lgmm(w k n) liv(yr1978-yr1984) vce(robust) two hascons
xtabond2 n L.n L(0/1).(w k) yr1978-yr1984, gmm(L.(w k n)) iv(yr1978-yr1984, eq(level)) h(2) robust twostep
* Three ways to reduce the instrument count
xtabond2 n L.n L(0/1).(w k) yr1978-yr1984, gmm(L.(w k n)) iv(yr1978-yr1984, eq(level)) h(2) robust twostep pca
xtabond2 n L.n L(0/1).(w k) yr1978-yr1984, gmm(L.(w k n), collapse) iv(yr1978-yr1984, eq(level)) h(2) robust twostep
xtabond2 n L.n L(0/1).(w k) yr1978-yr1984, gmm(L.(w k n), lag(1 1)) iv(yr1978-yr1984, eq(level)) h(2) robust twostep
* Estimation a la Hayakawa 2009
xtabond2 n L.n L(0/1).(w k) yr1979-yr1984, gmm(L.(w k n), lag(1 1) orthog) iv(yr1979-yr1984) h(2) robust twostep orthog noleveleq
***xtseqreg Example***
webuse psidextract
*** Fit a first-stage model for time-varying indepvars with OLS
xtseqreg lwage wks south smsa ms exp exp2 occ ind union
***Fit a second-stage model for time-invariant indepvars with OLS
xtseqreg lwage (wks south smsa ms exp exp2 occ ind union) fem blk ed

Comment