I am writing the following program:
I need help to write this:
in the form
or some other form that allows me to write "1-k" equations in short so that if I have very large 'k', I do not need to mention all equations one by one.
Thanks in advance for your help.
Rabiul
HTML Code:
clear all
program define svywt
version 15.1
syntax varlist, WTvar(varlist)
gettoken depvar indepvars : varlist
_fv_check_depvar `depvar'
local k: word count `wtvar'
forvalues i = 2/`k'{
local 1(1:`:word 1 of `wtvar''/(1+{xb: `wtvar'})) //this equation has been written manually to provide linear combinations xb.
local `i'(`i':`:word `i' of `wtvar''/(1+{xb: }))
}
local last(last:(`depvar' - ({`depvar': `indepvars' _cons}))/ (1+{xb: }))
local last_inst instruments(last: `indepvars')
gmm `1' `2'``k'' `last', `last_inst' onestep winitial(unadjusted, independent) //help needed in this part
end
sysuse auto, clear
egen y = mean(price)
gen price_1 = price -y
egen x = mean(mpg)
gen mpg_1=mpg-x
egen z =mean(trunk)
gen trunk_1 = trunk-z
svywt price weight mpg, wtvar(price_1 mpg_1 trunk_1)
HTML Code:
gmm `1' `2'``k'' `last', `last_inst' onestep winitial(unadjusted, independent)
HTML Code:
gmm `1' -``k'' `last', `last_inst' onestep winitial(unadjusted, independent)
Thanks in advance for your help.
Rabiul
