Hello,
I am attempting to use a dynamic list of globals as an input into sureg. In particular, in the program setup I am requiring a user to declare both the number of equations and globals representing the equations:
Thanks,
Erica
The full code is below:
I am attempting to use a dynamic list of globals as an input into sureg. In particular, in the program setup I am requiring a user to declare both the number of equations and globals representing the equations:
I later use a forvalues loop to build the input list for sureg:
Code:set more off //Load data here sysuse auto, clear*Specify model equations *Set the number of equations after the equal sign scalar numEquations = 3 *Each equation should have a global declaration of the form : *global eq1 (Y X1 X2 ...Xk) *Example global eq1 (price foreign weight length) global eq1 (price foreign weight length) global eq2 (mpg foreign weight) global eq3 (displ foreign weight)
Code:
*List which equations to include in the regression
forvalues i=1(1)`=numEquations' {
local tmp "eq`i'" local eqList `eqList' char(36)+`tmp'+char(32)
}
di "`eqList'"
However, when I call sureg:
I am getting an error, "coding operators not allowed". Any assistance on this issue would be much appreciated.
Code:sureg `eqList', const(`constList')
Thanks,
Erica
The full code is below:
Code:
set more off
//Load data here
sysuse auto, clear
////////////////////////////////////////////////////////////
/*Step One: Regression setup */
//////////////////////////////////////////////////////////
*Specify model equations
*Set the number of equations after the equal sign
scalar numEquations = 3
*Each equation should have a global declaration of the form :
*global eq1 (Y X1 X2 ...Xk)
*Example global eq1 (price foreign weight length)
global eq1 (price foreign weight length)
global eq2 (mpg foreign weight)
global eq3 (displ foreign weight)
////////////////////////////////////////////////////////////
/*Step Two: Run Regression */
//////////////////////////////////////////////////////////
*List which equations to include in the regression
forvalues i=1(1)`=numEquations' {
local tmp "eq`i'"
local eqList `eqList' char(36)+`tmp'+char(32)
}
di "`eqList'"
sureg `eqList'

Comment