Hi Stata Users!
I have the following lines of program. The program itself seems to work, but for some reason I encounter a problem of syntax specification, when I try to run it.
Is it possible to have a variable list and number as an input? Or it could be a problem with e()/r() class conflict within the program, as well?
Thank you very much for your answers in advance!
Lorand
program bootstrap123, eclass
version 13
syntax varlist(min=2 numeric) namelist(max=1 numeric) [, ESTIMATES]
gettoken y x: varlist
local sizeofvar: list sizeof x
local sizeofvar1 = sizeofvar + 1
quietly reg `y' `x'
mat coef1=e(b)
mat coef3=J(`namelist',`sizeofvar1',.)
foreach i of numlist 1/`sizeofvar1' {
forvalues v = 1/`namelist' {
bsample _N
quietly reg `y' `x'
mat coef2_`v'=e(b)
mat coef3[`v',`i'] = coef2_`v'[1,`i']
}
}
svmat coef3, names(col)
mat std1=J(`namelist',`sizeofvar1',.)
foreach i of numlist 1/`sizeofvar1' {
quietly sum c`i'
mat std1[1,`i']=r(sd)
}
mat output = coef1 \ std1
mat list output
if "`estimates'" == "estimates" {
mat list coef3
}
drop c*
end
I have the following lines of program. The program itself seems to work, but for some reason I encounter a problem of syntax specification, when I try to run it.
Is it possible to have a variable list and number as an input? Or it could be a problem with e()/r() class conflict within the program, as well?
Thank you very much for your answers in advance!
Lorand
program bootstrap123, eclass
version 13
syntax varlist(min=2 numeric) namelist(max=1 numeric) [, ESTIMATES]
gettoken y x: varlist
local sizeofvar: list sizeof x
local sizeofvar1 = sizeofvar + 1
quietly reg `y' `x'
mat coef1=e(b)
mat coef3=J(`namelist',`sizeofvar1',.)
foreach i of numlist 1/`sizeofvar1' {
forvalues v = 1/`namelist' {
bsample _N
quietly reg `y' `x'
mat coef2_`v'=e(b)
mat coef3[`v',`i'] = coef2_`v'[1,`i']
}
}
svmat coef3, names(col)
mat std1=J(`namelist',`sizeofvar1',.)
foreach i of numlist 1/`sizeofvar1' {
quietly sum c`i'
mat std1[1,`i']=r(sd)
}
mat output = coef1 \ std1
mat list output
if "`estimates'" == "estimates" {
mat list coef3
}
drop c*
end
Comment