Hi
I am trying to write up a moment evaluator program that can be fed into a GMM routine. I am stuck at one of the examples provided in the stata help. The program is given below

Code:
program gmm_ivreg

version 16

syntax varlist [if] , at(name) rhs(varlist) depvar(varlist)

tempvar m
quietly gen double `m' = 0 `if'
local i 1
foreach var of varlist `rhs' {
quietly replace `m' = `m' + `var'*`at'[1,`i'] `if'
local `++i'
}
quietly replace `m' = `m' + `at'[1,`i'] `if' // constant

quietly replace `varlist' = `depvar' - `m' `if'

end
I don't understand what the last line does - replace `varlist' = `depvar' - `m' `if' - Can you help me understand what this does? What exactly is `varlist' here referring to?