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

Re: st: Using GMM with Moment-Evaluator Program

From   "Brian P. Poi" <>
Subject   Re: st: Using GMM with Moment-Evaluator Program
Date   Tue, 16 Feb 2010 10:30:11 -0600 (CST)

On Tue, 16 Feb 2010, odongo kodongo wrote:

Dear all,

I am trying to run the following program, which in all respects, is similar
to the illustration given in the "Help GMM" of Stata 11/SE.

program tryagain
version 11
syntax varlist if, at(name) rhsvar(varlist) lhsvar(varlist)
quietly {
   tempvar xb
   generate double `xb' = 0 `if'
   local i = 1
   foreach var of varlist `rhsvar' {
       replace `xb' = `xb' + `at'[1,`i']*`var' `if'     // coefficients
       local `++i'
   replace `xb' = `xb' + `at'[1,`i'] `if'                // constant term
   replace varlist = `lhsvar' - `xb' `if'                // model's residuals

When I run it, I get the following error messages:

error calling tryagain at initial values
variable varlist not found

varlist is a local macro that you need to dereference, so this line:

    replace varlist = `lhsvar' - `xb' `if'                // model's residuals

should read

    replace `varlist' = `lhsvar' - `xb' `if'              // model's residuals

  -- Brian Poi
*   For searches and help try:

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