Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: Moment evaluator programs with K equations


From   odongo kodongo <odongo.kodongo@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Moment evaluator programs with K equations
Date   Wed, 17 Feb 2010 17:46:50 +0200

Thanks so much Brian. Let me try these suggestions.

On Wed, Feb 17, 2010 at 5:31 PM, Brian P. Poi <bpoi@stata.com> wrote:

>
> On Wed, 17 Feb 2010, Christopher Kodongo wrote:
>
>  Dear statalisters
>>
>> Something appears to be fundamentally wrong with the following program.
>> Trouble is - I can't spot it. Can you?
>>
>> program tryagain2, eclass
>> version 11
>> syntax varlist [if], at(name) depvars(varlist) indvars(varlist)
>> quietly {
>>     tempvar xb
>>     generate double `xb' = 0 `if'
>>     local k = 1
>>     local i = 1
>>     foreach var of varlist `depvars' {
>>         foreach var of varlist `indvars' {
>>             replace `xb' = `xb' + `at'[`k',`i']*`var' `if'
>>             local `++i'
>>         }
>>         local `++k'
>>     }
>>     replace `xb' = `xb' + `at'[`k',`i'] `if'
>>     replace `varlist' = `depvars' - `xb' `if'
>> }
>> end
>>
>> gmm tryagain2, nequations(3) parameters(wldemr usaemr _cons) ///
>>     depvars(kenemr moremr zaremr) indvars(wldemr usaemr) ///
>>     instruments(nigemr empemr zaremr) wmatrix(robust) vce(hac bartlett 2)
>> igmm
>>
>
>
> Since you specified three parameters in the parameters() option, the `at'
> vector is going to be 1 by 3; even if you have multiple equations, the
> parameters are packed as a row vector, not a matrix.
>
> Also, since you specified nequations(3), the local macro `varlist' has
> three words in it.  Part of your program will end up looking something like
> this:
>
>   local m1 : word 1 of `varlist'
>   local m2 : word 2 of `varlist'
>   local m3 : word 3 of `varlist'
>   local dv1 : word 1 of `depvars'
>   local dv2 : word 2 of `depvars'
>   local dv3 : word 3 of `depvars'
>   replace `m1' = `dv1' - (something that depends on `at' and `indvars')
>   replace `m2' = `dv2' - (something that depends on `at' and `indvars')
>   replace `m3' = `dv3' - (something that depends on `at' and `indvars')
>
>
>   -- Brian Poi
>   -- bpoi@stata.com

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index