Dear all,
I am trying to create a specific table from Stata output, and have tried to do so using esttab, estout, outreg2 and asdoc, but do not get the desired result. I have 11 y-variables, and regress them on the variable treatment and some other x-variables using a loop like this:
local y_vars y1 y2 ...
local x_vars x1 x2 ...
local i = 1
foreach var of local y_vars{
qui probit `var' treatment `x_vars'
estimates store m`i'
local ++i
Now, I would like to create a table where the variable treatment is the column header (other x-vars are irrelevant, just for control), and the 11 dependent variables feature in different rows. Ideally, I would like to add two further columns, where treatment is defined differently (see structure below).
After browsing on the forum, I used this code to create something remotely resembling what I want:
esttab m1 m2 m3 m4 m5 m6 m7 m8 m9 m10 m11, keep(treatment) se nostar
matrix C = r(coefs)
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
quietly estadd matrix se
}
esttab using Test.doc, replace se starlevels(* 0.1 ** 0.05 *** 0.01) title("Probit regressions, binary dependent variables") mtitle("All provinces") modelwidth(30) varwidth(30) nogaps lines compress
eststo clear
However, this seems quite complicated and i don't know how to add further columns. Can you recommend a different way to do this? Which would be the most appropriate package to use?
All help is much appreciated, please excuse the long post.
Kind regards, Elisabeth
I am trying to create a specific table from Stata output, and have tried to do so using esttab, estout, outreg2 and asdoc, but do not get the desired result. I have 11 y-variables, and regress them on the variable treatment and some other x-variables using a loop like this:
local y_vars y1 y2 ...
local x_vars x1 x2 ...
local i = 1
foreach var of local y_vars{
qui probit `var' treatment `x_vars'
estimates store m`i'
local ++i
Now, I would like to create a table where the variable treatment is the column header (other x-vars are irrelevant, just for control), and the 11 dependent variables feature in different rows. Ideally, I would like to add two further columns, where treatment is defined differently (see structure below).
Treatment | Treatment 2 | Treatment3 | |
Dependent variables | |||
Y1 | |||
Y2 | |||
Y3 etc. |
After browsing on the forum, I used this code to create something remotely resembling what I want:
esttab m1 m2 m3 m4 m5 m6 m7 m8 m9 m10 m11, keep(treatment) se nostar
matrix C = r(coefs)
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
quietly estadd matrix se
}
esttab using Test.doc, replace se starlevels(* 0.1 ** 0.05 *** 0.01) title("Probit regressions, binary dependent variables") mtitle("All provinces") modelwidth(30) varwidth(30) nogaps lines compress
eststo clear
However, this seems quite complicated and i don't know how to add further columns. Can you recommend a different way to do this? Which would be the most appropriate package to use?
All help is much appreciated, please excuse the long post.
Kind regards, Elisabeth
Comment