Hi,
I am using -estout- (available from SSC) to stack models but since my independent variable is the same using the -, refcat()- option isn't working. I know why this isn't working, but would anyone know if there's a workaround? I would like a table like the following:
Here's the code that I currently have:
I am using -estout- (available from SSC) to stack models but since my independent variable is the same using the -, refcat()- option isn't working. I know why this isn't working, but would anyone know if there's a workaround? I would like a table like the following:
Code:
-------------------------
(1)
-------------------------
All
weight 2.044
(0.377)
Domestic
weight 2.995
(0.466)
Foreign
weight 5.362
(0.629)
-------------------------
N
-------------------------
Code:
capt prog drop appendmodels
*! version 1.0.0 14aug2007 Ben Jann
program appendmodels, eclass
// using first equation of model
syntax namelist
tempname b V tmp
foreach name of local namelist {
qui est restore `name'
mat `tmp' = e(b)
local eq1: coleq `tmp'
gettoken eq1 : eq1
mat `tmp' = `tmp'[1,"`eq1':"]
local cons = colnumb(`tmp',"_cons")
if `cons'<. & `cons'>1 {
mat `tmp' = `tmp'[1,1..`cons'-1]
}
mat `b' = nullmat(`b') , `tmp'
mat `tmp' = e(V)
mat `tmp' = `tmp'["`eq1':","`eq1':"]
if `cons'<. & `cons'>1 {
mat `tmp' = `tmp'[1..`cons'-1,1..`cons'-1]
}
capt confirm matrix `V'
if _rc {
mat `V' = `tmp'
}
else {
mat `V' = ///
( `V' , J(rowsof(`V'),colsof(`tmp'),0) ) \ ///
( J(rowsof(`tmp'),colsof(`V'),0) , `tmp' )
}
}
local names: colfullnames `b'
mat coln `V' = `names'
mat rown `V' = `names'
eret post `b' `V'
eret local cmd "whatever"
end
sysuse auto, clear
* ssc install estout, replace
eststo m0: qui reg price weight
eststo m1: qui reg price weight if foreign == 0
eststo m2: qui reg price weight if foreign == 1
eststo mstack: appendmodels m0 m1 m2
esttab mstack, keep(weight) se nostar ///
refcat(weight "All" weight "Domestic" weight "Foreign", nolabel)

Comment