Examples for eststo

Basic syntax and usage

eststo stores a copy of the active estimation results for later tabulation. It is an alternative to official Stata's estimates store. The basic syntax of eststo is:

eststo [name] [, options ] [ : estimation_command ]

eststo may be applied analogous to official Stata's estimates store. Example:

. sysuse auto
(1978 Automobile Data)

. quietly regress price weight mpg

. eststo model1

. quietly regress price weight mpg foreign

. eststo model2

. estimates table model1 model2

----------------------------------------
    Variable |   model1       model2    
-------------+--------------------------
      weight |  1.7465592    3.4647058  
         mpg | -49.512221    21.853604  
     foreign |               3673.0604  
       _cons |  1946.0687   -5853.6957  
----------------------------------------

. eststo clear

[do-file]

eststo clear on the last line of the example erases the estimation sets that have been stored by eststo.

Store estimates without providing a name

A main advantage of eststo over estimates store is that it does not require the user to specify a name for the stored estimates. Example:

. sysuse auto
(1978 Automobile Data)

. quietly regress price weight mpg

. eststo
(est1 stored)

. quietly regress price weight mpg foreign

. eststo
(est2 stored)

. esttab

--------------------------------------------
                      (1)             (2)   
                    price           price   
--------------------------------------------
weight              1.747**         3.465***
                   (2.72)          (5.49)   

mpg                -49.51           21.85   
                  (-0.57)          (0.29)   

foreign                            3673.1***
                                   (5.37)   

_cons              1946.1         -5853.7   
                   (0.54)         (-1.73)   
--------------------------------------------
N                      74              74   
--------------------------------------------
t statistics in parentheses
* p<0.05, ** p<0.01, *** p<0.001

. eststo clear

[do-file]

eststo keeps a list of the names of the stored estimation sets. If, as above, esttab (or estout) is applied without specifying the names of the sets to be tabulated, all sets stored by eststo are tabulated.

Use eststo as a prefix command

eststo may be used as a prefix command:

. sysuse auto
(1978 Automobile Data)

. eststo: quietly regress price weight mpg
(est1 stored)

. eststo: quietly regress price weight mpg foreign
(est2 stored)

. esttab

--------------------------------------------
                      (1)             (2)   
                    price           price   
--------------------------------------------
weight              1.747**         3.465***
                   (2.72)          (5.49)   

mpg                -49.51           21.85   
                  (-0.57)          (0.29)   

foreign                            3673.1***
                                   (5.37)   

_cons              1946.1         -5853.7   
                   (0.54)         (-1.73)   
--------------------------------------------
N                      74              74   
--------------------------------------------
t statistics in parentheses
* p<0.05, ** p<0.01, *** p<0.001

. eststo clear

[do-file]

Using by with eststo

If eststo is used as a prefix command, the by command is allowed to obtain results for different groups of observations:

. sysuse auto
(1978 Automobile Data)

. by foreign: eststo: quietly reg price weight mpg

-------------------------------------------------------------------------------
-> Domestic
(est1 stored)

-------------------------------------------------------------------------------
-> Foreign
(est2 stored)

. esttab, label nodepvar nonumber

----------------------------------------------------
                         Domestic         Foreign   
----------------------------------------------------
Weight (lbs.)               4.415***        5.156***
                           (4.66)          (5.85)   

Mileage (mpg)               237.7          -19.78   
                           (1.71)         (-0.34)   

Constant                 -13285.4*        -5065.8   
                          (-2.32)         (-1.58)   
----------------------------------------------------
Observations                   52              22   
----------------------------------------------------
t statistics in parentheses
* p<0.05, ** p<0.01, *** p<0.001

. eststo clear

[do-file]

Add additional statistics

eststo can add extra results to the e()-scalars while storing the estimates and thus make them available for tabulation. Example:

. sysuse auto
(1978 Automobile Data)

. quietly regress price weight mpg

. test weight = mpg

 ( 1)  weight - mpg = 0

       F(  1,    71) =    0.36
            Prob > F =    0.5514

. eststo, addscalars(p_diff r(p))
(e(p_diff) = .55138216 added)
(est1 stored)

. esttab, scalars(p_diff) obslast

----------------------------
                      (1)   
                    price   
----------------------------
weight              1.747** 
                   (2.72)   

mpg                -49.51   
                  (-0.57)   

_cons              1946.1   
                   (0.54)   
----------------------------
p_diff              0.551   
N                      74   
----------------------------
t statistics in parentheses
* p<0.05, ** p<0.01, *** p<0.001

. eststo clear

[do-file]

Functionality of the addscalars() option is limited to adding scalars. See the estadd command for a more powerful tool to add results to stored estimates.

Drop the e(sample) to save memory

eststo can store the estimates without the e(sample) function. Excluding e(sample) saves memory and speeds up tabulation programs. Example:

. sysuse auto
(1978 Automobile Data)

. eststo: quietly regress price weight mpg
(est1 stored)

. eststo, noesample: quietly regress price weight mpg
(est2 stored)

. _eststo: quietly regress price weight mpg
(est3 stored)

. estimates dir

-------------------------------------------------------
        name | command      depvar       npar  title 
-------------+-----------------------------------------
        est1 | regress      price           3  
        est2 | regress      price           3  
        est3 | regress      price           3  
-------------------------------------------------------

. describe _est*

              storage  display     value
variable name   type   format      label      variable label
-------------------------------------------------------------------------------
_est_est1       byte   %8.0g                  esample() from estimates store

. eststo clear

[do-file]

_eststo is a synonym for eststo with the noesample option specified

Cautionary note: Some postestimation commands may not work correctly with estimates that do not contain the e(sample).