I am looping over several independent variables, and I am trying to end up with a matrix that combines results for each regression. With one empty row separating results.
This is the code I have written so far, which overwrites instead of appends:
Code:
local indicators employment degree
local invars X Y
foreach depvar of local indicators{
foreach invar of local invars{
matrix result_`invar'=J(1, 3, .)
svy: regress `depvar' dummy if Year==2010 & invars==`invar'
matrix temp1_`invar'`=r(table)
matselrc temp1_`invar' temp2_`invar', c(1) r(1 2 4)
matrix temp2_`invar' = temp2_`invar''
matrix result_`invar'= result_`invar'\temp2_`invar'
}
}And I know things like outreg or esttab would be easier, but unfortunately I need my results in matrix format.
Can anyone help me with this?
Thank you.
0 Response to Appending to a matrix in a loop
Post a Comment