Dear Stata-Listers,
I estimate several models, which always contain the same coefficient of interest. Then I do the same with another outcome, and the same coefficient of interest (the structure of the models remains the same for the second outcome). Then I'd like to have a table, where each row shows the coefficient of interest and each column represents one of the different outcomes. Thus, I want something like this:
Following, I copied an example from http://repec.org/bocode/e/estout/adv...ml#advanced905 which provides me with the solution with one single column, the one with weight as outcome.
(the output table can be found on the website posted above)
I can only keep e.g. weight as coefficient of interest by adding esttab "keep(weight)" to the first esttab command. Then I have two rows, one for each model estimated, and one column.
Due to the fact that I am not very familiar with matrix programming in Stata, I am really struggling how to extend this example to a second column, which e.g. estimates the same models with rep78 as outcome:
Thus, the second row would again display the result of the weight coefficient, but now on rep78.
I estimate several models, which always contain the same coefficient of interest. Then I do the same with another outcome, and the same coefficient of interest (the structure of the models remains the same for the second outcome). Then I'd like to have a table, where each row shows the coefficient of interest and each column represents one of the different outcomes. Thus, I want something like this:
| price outcome | rep78 outcome | |
| Model 1 | outcome 1 ** (s.e.) |
outcome 3* (s.e.) |
| Model 2 | outcome 2 ** (s.e.) |
outcome 4 (s.e.) |
Following, I copied an example from http://repec.org/bocode/e/estout/adv...ml#advanced905 which provides me with the solution with one single column, the one with weight as outcome.
Code:
sysuse auto
eststo model1: quietly reg price weight
eststo model2: quietly reg price weight mpg
esttab model1 model2, se nostar
matrix c = r(coefs)
mat list c
eststo clear
local rnames : rownames c
local models : coleq c
local models : list uniq models
local i 0
foreach name of local rnames {
local ++i
local j 0
capture matrix drop b
capture matrix drop se
foreach model of local models {
local ++j
matrix tmp = c[`i', 2*`j'-1]
if tmp[1,1]<. {
matrix colnames tmp = `model'
matrix b = nullmat(b), tmp
matrix tmp[1,1] = c[`i', 2*`j']
matrix se = nullmat(se), tmp
}
}
ereturn post b
estadd matrix se
eststo `name'
}
esttab , se mtitle noob
I can only keep e.g. weight as coefficient of interest by adding esttab "keep(weight)" to the first esttab command. Then I have two rows, one for each model estimated, and one column.
Due to the fact that I am not very familiar with matrix programming in Stata, I am really struggling how to extend this example to a second column, which e.g. estimates the same models with rep78 as outcome:
Code:
sysuse auto eststo model1: quietly reg rep78 weight eststo model2: quietly reg rep78 weight mpg

Comment