|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: st: Moment evaluator programs with K equations
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
-- [email protected]