Dear Statalisters,
I am interested in estimating a two-equation system by GMM, using two different estimation samples, one for each equation. In particular, to fit the first equation I can only use those observations for which one of my variables -let's call it select- is equal to 1, and to fit the second equation I can only use the observations for which select is equal to zero.
If I were interested in using the same estimation sample for both equations, my code would be like:
where y1 is the dependent variable of the first equation, y2 is the dependent variable of the second equation, year_* is used to call a list of variables starting by "year_";`varlist1' and `varlist2' are two locals I am using to store two sets of regressors, and I am using the variable wt as probability weights.
I would like to know if there is a way to write the condition I mentioned above, so that the first equation is fitted with the observations for which select is equal to 1, and the second equation equation with those for which select is equal to zero. I have been trying to approach the problem using the moment-evaluator program version of gmm, but I am not getting it right. This is what I tried:
where `allvars' is a local containing the year_* variables I mentioned before and those in `varlist1', and `ly' and `fy' are two parameters I use to define the set of year_* variables (I generate `ly'-`fy'+1 variables, i.e., these variables are year_`fy', year_`fy+1',..., year_`ly').
I am interested in estimating a two-equation system by GMM, using two different estimation samples, one for each equation. In particular, to fit the first equation I can only use those observations for which one of my variables -let's call it select- is equal to 1, and to fit the second equation I can only use the observations for which select is equal to zero.
If I were interested in using the same estimation sample for both equations, my code would be like:
Code:
gmm (eqa: y1 - ({xb1: year_*})*exp({xb2:`varlist1'})) /// (eqb: y2 - exp({xb3:`varlist1'})+exp({xb4:`varlist2'})) [pw=wt], /// instruments(eqa: year_* `varlist1') /// instruments(eqb: `varlist1' `varlist2')
I would like to know if there is a way to write the condition I mentioned above, so that the first equation is fitted with the observations for which select is equal to 1, and the second equation equation with those for which select is equal to zero. I have been trying to approach the problem using the moment-evaluator program version of gmm, but I am not getting it right. This is what I tried:
Code:
program jointgmm, eclass version 15.1 syntax resideq(min=2 max=2) [if] [pweight/], at(name) quietly { local resideq1 : word 1 of `resideq' local resideq2 : word 2 of `resideq' local if1 : word 1 of `if' local if2 : word 2 of `if' replace `if1' = (select==1) replace `if2' = (select==0) gen double `xb1' = 0 `if1' local i=1 foreach var of local allvars { replace `xb1'=`xb1'+`at'[1,`i']*`var' `if1' local `++i' } gen double `xb3' = 0 `if2' local i=`ly'-`fy'+2 foreach var of local varlist1 { replace `xb2'=`xb2'+`at'[1,`i']*`var' `if2' local `++i' } gen double `xb4' = 0 `if2' local i=`ly'-`fy'+2 foreach var of local varlist2 { replace `xb3'=`xb3'+`at'[1,`i']*`var' `if2' local `++i' } replace `resideq1' = y1- `xb1' `if1' replace `resideq2' = y2- exp(`xb3') + exp(`xb4') `if2' } end local np=0 foreach v of local allvars { local ++np } gmm jointgmm [pw=wt], nequations(2) nparameters(`np') /// instruments(1: year_* `varlist1') instruments(2: `varlist1' `varlist2')
Comment