Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: estout: table of several univariate results in one column and esttab error


From   "Ben Jann" <[email protected]>
To   [email protected]
Subject   Re: st: estout: table of several univariate results in one column and esttab error
Date   Sun, 17 Jun 2007 22:36:57 +0200

Jannik, I'll answer your second question first.
2. Esttab error:: When I use esttab in the command line of stata- I
get the following error [...]
It seems that you have different versions of -estout- on your system.
Probably, there is an old -estout- version laying around in your
working directory.

1. Is it somehow possible to  get esta/esttab to list several
estimation (e.g esto1+ esto2+ esto3) in a single column?
Someone else asked the same question a month ago or so. Below is a
copy of my answer.

ben


You need to merge the single bivariate models into one estimation set
before tabulating them in estout. This requires some programming.
[...]

***start of do-file***
capt prog drop mergemodels
prog mergemodels, eclass
// assuming that last element in e(b)/e(V) is _cons
 version 8
 syntax namelist
 tempname b V tmp
 foreach name of local namelist {
   qui est restore `name'
   mat `b' = nullmat(`b') , e(b)
   mat `b' = `b'[1,1..colsof(`b')-1]
   mat `tmp' = e(V)
   mat `tmp' = `tmp'[1..rowsof(`tmp')-1,1..colsof(`tmp')-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
qui reg price weight
est sto u1
qui reg price mpg
est sto u2
qui xi: reg price i.rep78
est sto u3
set trace off
mergemodels u1 u2 u3
est sto u123
estout u1 u2 u3 u123, style(smcl)
qui xi: reg price weight mpg i.rep78
est sto m
estout u123 m, style(smcl)
***end of do-file***

***output***
. capt prog drop mergemodels

. prog mergemodels, eclass
 1. // assuming that last element in e(b)/e(V) is _cons
.   version 8
 2.   syntax namelist
 3.   tempname b V tmp
 4.   foreach name of local namelist {
 5.     qui est restore `name'
 6.     mat `b' = nullmat(`b') , e(b)
 7.     mat `b' = `b'[1,1..colsof(`b')-1]
 8.     mat `tmp' = e(V)
 9.     mat `tmp' = `tmp'[1..rowsof(`tmp')-1,1..colsof(`tmp')-1]
10.     capt confirm matrix `V'
11.     if _rc {
12.       mat `V' = `tmp'
13.     }
14.     else {
15.       mat `V' = ///
       ( `V' , J(rowsof(`V'),colsof(`tmp'),0) ) \ ///
       ( J(rowsof(`tmp'),colsof(`V'),0) , `tmp' )
16.     }
17.   }
18.   local names: colfullnames `b'
19.   mat coln `V' = `names'
20.   mat rown `V' = `names'
21.   eret post `b' `V'
22.   eret local cmd "whatever"
23. end

.
. sysuse auto
(1978 Automobile Data)

. qui reg price weight

. est sto u1

. qui reg price mpg

. est sto u2

. qui xi: reg price i.rep78

. est sto u3

. set trace off

. mergemodels u1 u2 u3

. est sto u123

. estout u1 u2 u3 u123, style(smcl)

----------------------------------------------------------------
                      u1           u2           u3         u123
                       b            b            b            b
----------------------------------------------------------------
weight           2.044063                               2.044063
mpg                          -238.8943                 -238.8943
_Irep78_2                                  1403.125     1403.125
_Irep78_3                                  1864.733     1864.733
_Irep78_4                                      1507         1507
_Irep78_5                                    1348.5       1348.5
_cons           -6.707353     11253.06       4564.5
----------------------------------------------------------------

. qui xi: reg price weight mpg i.rep78

. est sto m

. estout u123 m, style(smcl)

--------------------------------------
                    u123            m
                       b            b
--------------------------------------
weight           2.044063     2.093066
mpg             -238.8943     -63.0971
_Irep78_2        1403.125     753.7024
_Irep78_3        1864.733     1349.361
_Irep78_4            1507      2030.47
_Irep78_5          1348.5      3376.91
_cons                        -598.9665
--------------------------------------

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index