Examples for estpost

Basic syntax and usage

esttab and estout tabulate the e()-returns of a command, but not all commands return their results in e(). estpost is a tool make results from some of the most popular of these non-"e-class" commands available for tabulation. It collects results and posts them in an appropriate form in e(). The basic syntax of estpost is:

estpost command [ arguments ] [, options ]

See the help file for a list of supported commands. For example, to post and then results from summarize you could type:

. sysuse auto
(1978 Automobile Data)

. estpost summarize price weight rep78 mpg

             |  e(count)   e(sum_w)    e(mean)     e(Var)      e(sd) 
-------------+-------------------------------------------------------
       price |        74         74   6165.257    8699526   2949.496 
      weight |        74         74   3019.459   604029.8   777.1936 
       rep78 |        69         69   3.405797   .9799659   .9899323 
         mpg |        74         74    21.2973   33.47205   5.785503 

             |    e(min)     e(max)     e(sum) 
-------------+---------------------------------
       price |      3291      15906     456229 
      weight |      1760       4840     223440 
       rep78 |         1          5        235 
         mpg |        12         41       1576 

. esttab, cells("count mean sd min max") noobs

-----------------------------------------------------------------------------
                      (1)                                                    
                                                                             
                    count         mean           sd          min          max
-----------------------------------------------------------------------------
price                  74     6165.257     2949.496         3291        15906
weight                 74     3019.459     777.1936         1760         4840
rep78                  69     3.405797     .9899323            1            5
mpg                    74      21.2973     5.785503           12           41
-----------------------------------------------------------------------------

[do-file]

Applications

Post summary statistics (summarize)

Example for estpost summarize:

. sysuse auto
(1978 Automobile Data)

. estpost summarize price mpg rep78 foreign, listwise

             |  e(count)   e(sum_w)    e(mean)     e(Var)      e(sd) 
-------------+-------------------------------------------------------
       price |        69         69   6146.043    8482308    2912.44 
         mpg |        69         69   21.28986   34.41475   5.866408 
       rep78 |        69         69   3.405797   .9799659   .9899323 
     foreign |        69         69   .3043478   .2148338   .4635016 

             |    e(min)     e(max)     e(sum) 
-------------+---------------------------------
       price |      3291      15906     424077 
         mpg |        12         41       1469 
       rep78 |         1          5        235 
     foreign |         0          1         21 

. esttab, cells("mean sd min max") nomtitle nonumber

----------------------------------------------------------------
                     mean           sd          min          max
----------------------------------------------------------------
price            6146.043      2912.44         3291        15906
mpg              21.28986     5.866408           12           41
rep78            3.405797     .9899323            1            5
foreign          .3043478     .4635016            0            1
----------------------------------------------------------------
N                      69                                       
----------------------------------------------------------------

[do-file]

Post summary statistics (tabstat)

Summary statistics can also be posted by estpost tabstat. Use columns(variables) and columns(statistics) to determine whether to display variables or statistics in the columns. The default is columns(variables):

. sysuse auto
(1978 Automobile Data)

. estpost tabstat price mpg rep78, listwise ///
>     statistics(mean sd)

Summary statistics: mean sd
     for variables: price mpg rep78

             |  e(price)     e(mpg)   e(rep78) 
-------------+---------------------------------
        mean |  6146.043   21.28986   3.405797 
          sd |   2912.44   5.866408   .9899323 

. esttab, cells("price mpg rep78") nomtitle nonumber

---------------------------------------------------
                    price          mpg        rep78
---------------------------------------------------
mean             6146.043     21.28986     3.405797
sd                2912.44     5.866408     .9899323
---------------------------------------------------
N                      69                          
---------------------------------------------------

[do-file]

Type columns(statistics) to print statistics in columns:

. sysuse auto
(1978 Automobile Data)

. estpost tabstat price mpg rep78, listwise ///
>     statistics(mean sd) columns(statistics)

Summary statistics: mean sd
     for variables: price mpg rep78

             |   e(mean)      e(sd) 
-------------+----------------------
       price |  6146.043    2912.44 
         mpg |  21.28986   5.866408 
       rep78 |  3.405797   .9899323 

. esttab, cells("mean sd") nomtitle nonumber

--------------------------------------
                     mean           sd
--------------------------------------
price            6146.043      2912.44
mpg              21.28986     5.866408
rep78            3.405797     .9899323
--------------------------------------
N                      69             
--------------------------------------

[do-file]

Post summary statistics by subgroups (summarize)

A table of summary statistics by subgroups can easily be produced using estpost summarize in connection with eststo and by:

. sysuse auto
(1978 Automobile Data)

. by foreign: eststo: quietly estpost summarize price mpg rep78, listwise

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

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

. esttab, cells("mean sd") label nodepvar

------------------------------------------------------------------------
                              (1)                       (2)             
                         Domestic                   Foreign             
                             mean           sd         mean           sd
------------------------------------------------------------------------
Price                     6179.25     3188.969     6070.143     2220.984
Mileage (mpg)            19.54167     4.753312     25.28571     6.309856
Repair Record 1978       3.020833      .837666     4.285714     .7171372
------------------------------------------------------------------------
Observations                   48                        21             
------------------------------------------------------------------------

. eststo clear

[do-file]

Alternatively, you can also use estpost tabstat (see next example).

Post summary statistics by subgroups (tabstat)

Use estpost tabstat with the by() option to post summary statistics by subgroups:

. sysuse auto
(1978 Automobile Data)

. estpost tabstat price mpg rep78, by(foreign) ///
>     statistics(mean sd) columns(statistics) listwise

Summary statistics: mean sd
     for variables: price mpg rep78
  by categories of: foreign

     foreign |   e(mean)      e(sd) 
-------------+----------------------
Domestic     |                      
       price |   6179.25   3188.969 
         mpg |  19.54167   4.753312 
       rep78 |  3.020833    .837666 
-------------+----------------------
Foreign      |                      
       price |  6070.143   2220.984 
         mpg |  25.28571   6.309856 
       rep78 |  4.285714   .7171372 
-------------+----------------------
Total        |                      
       price |  6146.043    2912.44 
         mpg |  21.28986   5.866408 
       rep78 |  3.405797   .9899323 

. esttab, main(mean) aux(sd) nostar unstack ///
>     noobs nonote nomtitle nonumber

---------------------------------------------------
                 Domestic      Foreign        Total
---------------------------------------------------
price              6179.2       6070.1       6146.0
                 (3189.0)     (2221.0)     (2912.4)

mpg                 19.54        25.29        21.29
                  (4.753)      (6.310)      (5.866)

rep78               3.021        4.286        3.406
                  (0.838)      (0.717)      (0.990)
---------------------------------------------------

[do-file]

If the labels of the categories are too long or contain unsuitable characters, they are stored in macro e(labels). Type varlabels(`e(labels)') or, depending on context, eqlabels(`e(labels)') to use these labels:

. sysuse auto
(1978 Automobile Data)

. estpost tabstat price in 1/15, by(make)

Summary statistics: mean
     for variables: price
  by categories of: make

        make |   e(mean) 
-------------+-----------
           1 |      4099 
           2 |      4749 
           3 |      3799 
           4 |      4816 
           5 |      7827 
           6 |      5788 
           7 |      4453 
           8 |      5189 
           9 |     10372 
          10 |      4082 
          11 |     11385 
          12 |     14500 
          13 |     15906 
          14 |      3299 
          15 |      5705 
-------------+-----------
       Total |    7064.6 

category labels saved in macro e(labels)

. esttab, cells(mean) noobs nomtitle nonumber ///
>     varlabels(`e(labels)') varwidth(20)

---------------------------------
                             mean
---------------------------------
AMC Concord                  4099
AMC Pacer                    4749
AMC Spirit                   3799
Buick Century                4816
Buick Electra                7827
Buick LeSabre                5788
Buick Opel                   4453
Buick Regal                  5189
Buick Riviera               10372
Buick Skylark                4082
Cad. Deville                11385
Cad. Eldorado               14500
Cad. Seville                15906
Chev. Chevette               3299
Chev. Impala                 5705
Total                      7064.6
---------------------------------

. lab def origin 0 "Car type: domestic" 1 "Car type: foreign", modify

. estpost tabstat price weight, statistics(mean sd) by(foreign)

Summary statistics: mean sd
     for variables: price weight
  by categories of: foreign

     foreign |  e(price)  e(weight) 
-------------+----------------------
1            |                      
        mean |  6072.423   3317.115 
          sd |  3097.104   695.3637 
-------------+----------------------
2            |                      
        mean |  6384.682   2315.909 
          sd |  2621.915   433.0035 
-------------+----------------------
Total        |                      
        mean |  6165.257   3019.459 
          sd |  2949.496   777.1936 

category labels saved in macro e(labels)

. esttab, cells("price weight") noobs nomtitle nonumber ///
>     eqlabels(`e(labels)') varwidth(20)

----------------------------------------------
                            price       weight
----------------------------------------------
Car type: domestic                            
mean                     6072.423     3317.115
sd                       3097.104     695.3637
----------------------------------------------
Car type: foreign                             
mean                     6384.682     2315.909
sd                       2621.915     433.0035
----------------------------------------------
Total                                         
mean                     6165.257     3019.459
sd                       2949.496     777.1936
----------------------------------------------

[do-file]

Post results from two-sample mean-comparison tests (ttest)

Example for estpost ttest:

. sysuse auto
(1978 Automobile Data)

. estpost ttest price mpg headroom trunk, by(foreign)

             |      e(b)   e(count)      e(se)       e(t)    e(df_t) 
-------------+-------------------------------------------------------
       price | -312.2587         74   754.4488  -.4138899         72 
         mpg | -4.945804         74   1.362162  -3.630848         72 
    headroom |  .5402098         74   .2070884   2.608596         72 
       trunk |  3.340909         74   1.022208   3.268327         72 

             |    e(p_l)       e(p)     e(p_u)     e(N_1)    e(mu_1) 
-------------+-------------------------------------------------------
       price |  .3400925   .6801851   .6599075         52   6072.423 
         mpg |  .0002627   .0005254   .9997373         52   19.82692 
    headroom |  .9944757   .0110486   .0055243         52   3.153846 
       trunk |    .99917     .00166     .00083         52      14.75 

             |    e(N_2)    e(mu_2) 
-------------+----------------------
       price |        22   6384.682 
         mpg |        22   24.77273 
    headroom |        22   2.613636 
       trunk |        22   11.40909 

. esttab, wide nonumber mtitle("diff.")

-----------------------------------------
                    diff.                
-----------------------------------------
price              -312.3         (-0.41)
mpg                -4.946***      (-3.63)
headroom            0.540*         (2.61)
trunk               3.341**        (3.27)
-----------------------------------------
N                      74                
-----------------------------------------
t statistics in parentheses
* p<0.05, ** p<0.01, *** p<0.001

[do-file]

Post results from two-group tests of proportions (prtest)

Example for estpost prtest:

. webuse cure2

. gen noise = uniform()>.5

. estpost prtest cure noise, by(sex)

             |      e(b)   e(count)      e(se)     e(se0)       e(z) 
-------------+-------------------------------------------------------
        cure | -.0729167        109   .0933123   .0942404  -.7737309 
       noise |  .0621528        109   .0965586   .0969397   .6411491 

             |    e(p_l)       e(p)     e(p_u)     e(N_1)     e(P_1) 
-------------+-------------------------------------------------------
        cure |   .219545     .43909    .780455         64     .59375 
       noise |  .7392871   .5214258   .2607129         64    .484375 

             |    e(N_2)     e(P_2) 
-------------+----------------------
        cure |        45   .6666667 
       noise |        45   .4222222 

. esttab, cell("b se0 z p") nomtitle nonumber

----------------------------------------------------------------
                        b          se0            z            p
----------------------------------------------------------------
cure            -.0729167     .0942404    -.7737309       .43909
noise            .0621528     .0969397     .6411491     .5214258
----------------------------------------------------------------
N                     109                                       
----------------------------------------------------------------

[do-file]

Post a one-way frequency table (tabulate)

Example for posting a one-way frequency table using estpost tabulate:

. sysuse auto
(1978 Automobile Data)

. estpost tabulate foreign

     foreign |      e(b)     e(pct)  e(cumpct) 
-------------+---------------------------------
    Domestic |        52   70.27027   70.27027 
     Foreign |        22   29.72973        100 
-------------+---------------------------------
       Total |        74        100            

. esttab, cells("b(label(freq)) pct(fmt(2)) cumpct(fmt(2))") ///
>     varlabels(, blist(Total "{hline @width}{break}"))      ///
>     nonumber nomtitle noobs

---------------------------------------------------
                     freq          pct       cumpct
---------------------------------------------------
Domestic               52        70.27        70.27
Foreign                22        29.73       100.00
---------------------------------------------------
Total                  74       100.00             
---------------------------------------------------

[do-file]

If the value labels are too long or contain unsuitable characters, they are stored in macro e(labels). Type varlabels(`e(labels)') to use the labels in esttab or estout in this case:

. sysuse auto
(1978 Automobile Data)

. lab def origin 0 "Car type: domestic" 1 "Car type: foreign", modify

. estpost tabulate foreign

     foreign |      e(b)     e(pct)  e(cumpct) 
-------------+---------------------------------
           0 |        52   70.27027   70.27027 
           1 |        22   29.72973        100 
-------------+---------------------------------
       Total |        74        100            

row labels saved in macro e(labels)

. esttab, cells("b(label(freq)) pct(fmt(2)) cumpct(fmt(2))")       ///
>     varlabels(`e(labels)', blist(Total "{hline @width}{break}")) ///
>     varwidth(20) nonumber nomtitle noobs

-----------------------------------------------------------
                             freq          pct       cumpct
-----------------------------------------------------------
Car type: domestic             52        70.27        70.27
Car type: foreign              22        29.73       100.00
-----------------------------------------------------------
Total                          74       100.00             
-----------------------------------------------------------

[do-file]

Post a two-way frequency table (tabulate)

estpost tabulate stores the columns of a two-way table in separate equations. Use the unstack option in esttab or estout to print these equations beside one another:

. sysuse auto
(1978 Automobile Data)

. estpost tabulate rep78 foreign

foreign      |                                            
       rep78 |      e(b)     e(pct)  e(colpct)  e(rowpct) 
-------------+--------------------------------------------
Domestic     |                                            
           1 |         2   2.898551   4.166667        100 
           2 |         8    11.5942   16.66667        100 
           3 |        27   39.13043      56.25         90 
           4 |         9   13.04348      18.75         50 
           5 |         2   2.898551   4.166667   18.18182 
       Total |        48   69.56522        100   69.56522 
-------------+--------------------------------------------
Foreign      |                                            
           1 |         0          0          0          0 
           2 |         0          0          0          0 
           3 |         3   4.347826   14.28571         10 
           4 |         9   13.04348   42.85714         50 
           5 |         9   13.04348   42.85714   81.81818 
       Total |        21   30.43478        100   30.43478 
-------------+--------------------------------------------
Total        |                                            
           1 |         2   2.898551   2.898551        100 
           2 |         8    11.5942    11.5942        100 
           3 |        30   43.47826   43.47826        100 
           4 |        18   26.08696   26.08696        100 
           5 |        11   15.94203   15.94203        100 
       Total |        69        100        100        100 

. esttab, cell(colpct(fmt(2))) unstack noobs

---------------------------------------------------
                      (1)                          
                                                   
                 Domestic      Foreign        Total
                   colpct       colpct       colpct
---------------------------------------------------
1                    4.17         0.00         2.90
2                   16.67         0.00        11.59
3                   56.25        14.29        43.48
4                   18.75        42.86        26.09
5                    4.17        42.86        15.94
Total              100.00       100.00       100.00
---------------------------------------------------

. esttab, cell(colpct(fmt(2)) b(fmt(g) par keep(Total))) ///
>     collabels(none) unstack noobs nonumber nomtitle    ///
>     eqlabels(, lhs("Repair Rec."))                     ///
>     varlabels(, blist(Total "{hline @width}{break}"))

---------------------------------------------------
Repair Rec.      Domestic      Foreign        Total
---------------------------------------------------
1                    4.17         0.00         2.90
2                   16.67         0.00        11.59
3                   56.25        14.29        43.48
4                   18.75        42.86        26.09
5                    4.17        42.86        15.94
---------------------------------------------------
Total              100.00       100.00       100.00
                     (48)         (21)         (69)
---------------------------------------------------

[do-file]

If the value labels are too long or contain unsuitable characters, they are stored in macros e(labels) (row labels) and e(eqlabels) (column labels). Type varlabels(`e(labels)') and eqlabels(`e(eqlabels)') to use these labels in esttab or estout:

. sysuse auto
(1978 Automobile Data)

. lab def origin 0 "Type: domestic" 1 "Type: foreign", modify

. lab def rep78 1 "Rep. rec. 1" 2 "Rep. rec. 2" 3 "Rep. rec. 3" 4 "Rep. rec. 4"
>  5 "Rep. rec. 5"

. lab val rep78 rep78

. estpost tabulate rep78 foreign

foreign      |                                            
       rep78 |      e(b)     e(pct)  e(colpct)  e(rowpct) 
-------------+--------------------------------------------
0            |                                            
           1 |         2   2.898551   4.166667        100 
           2 |         8    11.5942   16.66667        100 
           3 |        27   39.13043      56.25         90 
           4 |         9   13.04348      18.75         50 
           5 |         2   2.898551   4.166667   18.18182 
       Total |        48   69.56522        100   69.56522 
-------------+--------------------------------------------
1            |                                            
           1 |         0          0          0          0 
           2 |         0          0          0          0 
           3 |         3   4.347826   14.28571         10 
           4 |         9   13.04348   42.85714         50 
           5 |         9   13.04348   42.85714   81.81818 
       Total |        21   30.43478        100   30.43478 
-------------+--------------------------------------------
Total        |                                            
           1 |         2   2.898551   2.898551        100 
           2 |         8    11.5942    11.5942        100 
           3 |        30   43.47826   43.47826        100 
           4 |        18   26.08696   26.08696        100 
           5 |        11   15.94203   15.94203        100 
       Total |        69        100        100        100 

row labels saved in macro e(labels)
column labels saved in macro e(eqlabels)

. esttab, cell(colpct(fmt(2))) unstack noobs modelwidth(15) ///
>     varlabels(`e(labels)') eqlabels(`e(eqlabels)')

------------------------------------------------------------
                         (1)                                
                                                            
              Type: domestic   Type: foreign           Total
                      colpct          colpct          colpct
------------------------------------------------------------
Rep. rec. 1             4.17            0.00            2.90
Rep. rec. 2            16.67            0.00           11.59
Rep. rec. 3            56.25           14.29           43.48
Rep. rec. 4            18.75           42.86           26.09
Rep. rec. 5             4.17           42.86           15.94
Total                 100.00          100.00          100.00
------------------------------------------------------------

[do-file]

Post a one-way frequency table for complex survey data (svy: tabulate)

Example for posting a one-way frequency table for complex survey data using estpost svy: tabulate:

. webuse nhanes2b, clear

. svyset psuid [pweight=finalwgt], strata(stratid)

      pweight: finalwgt
          VCE: linearized
  Single unit: missing
     Strata 1: stratid
         SU 1: psuid
        FPC 1: <zero>

. estpost svy: tabulate race
(running tabulate on estimation sample)

Number of strata   =        31                Number of obs     =       10,351
Number of PSUs     =        62                Population size   =  117,157,513
                                              Design df         =           31

----------------------
1=white,  |
2=black,  |
3=other   | proportion
----------+-----------
    White |      .8792
    Black |      .0955
    Other |      .0253
          | 
    Total |          1
----------------------
  Key:  proportion  =  cell proportion

saved vectors:
             e(b) =  cell proportions
            e(se) =  standard errors of cell proportions
            e(lb) =  lower 95% confidence bounds for cell proportions
            e(ub) =  upper 95% confidence bounds for cell proportions
          e(deff) =  deff for variances of cell proportions
          e(deft) =  deft for variances of cell proportions
          e(cell) =  cell proportions
         e(count) =  weighted counts
           e(obs) =  number of observations

. esttab, cell("b(f(4)) se lb ub deft")

-----------------------------------------------------------------------------
                      (1)                                                    
                     Mean                                                    
                        b           se           lb           ub         deft
-----------------------------------------------------------------------------
White              0.8792       0.0167       0.8408       0.9093       5.2090
Black              0.0955       0.0127       0.0725       0.1249       4.4130
Other              0.0253       0.0105       0.0108       0.0585       6.8246
Total              1.0000       0.0000                                       
-----------------------------------------------------------------------------
N                   10351                                                    
-----------------------------------------------------------------------------

[do-file]

If the value labels are too long or contain unsuitable characters, they are stored in macro e(labels). Type varlabels(`e(labels)') in this case:

. label define race 1 "Race: White" 2 "Race: Black" 3 "Race: Other", modify

. estpost svy: tabulate race
(running tabulate on estimation sample)

Number of strata   =        31                Number of obs     =       10,351
Number of PSUs     =        62                Population size   =  117,157,513
                                              Design df         =           31

----------------------
1=white,  |
2=black,  |
3=other   | proportion
----------+-----------
 Race; Wh |      .8792
 Race; Bl |      .0955
 Race; Ot |      .0253
          | 
    Total |          1
----------------------
  Key:  proportion  =  cell proportion

saved vectors:
             e(b) =  cell proportions
            e(se) =  standard errors of cell proportions
            e(lb) =  lower 95% confidence bounds for cell proportions
            e(ub) =  upper 95% confidence bounds for cell proportions
          e(deff) =  deff for variances of cell proportions
          e(deft) =  deft for variances of cell proportions
          e(cell) =  cell proportions
         e(count) =  weighted counts
           e(obs) =  number of observations

row labels saved in macro e(labels)

. esttab, cell("b(f(4)) se lb ub deft") varlabels(`e(labels)')

-----------------------------------------------------------------------------
                      (1)                                                    
                     Mean                                                    
                        b           se           lb           ub         deft
-----------------------------------------------------------------------------
Race: White        0.8792       0.0167       0.8408       0.9093       5.2090
Race: Black        0.0955       0.0127       0.0725       0.1249       4.4130
Race: Other        0.0253       0.0105       0.0108       0.0585       6.8246
Total              1.0000       0.0000                                       
-----------------------------------------------------------------------------
N                   10351                                                    
-----------------------------------------------------------------------------

[do-file]

Post a two-way frequency table for complex survey data (svy: tabulate)

estpost svy: tabulate stores the columns of a two-way table in separate equations. Use the unstack option in esttab or estout to print these equations beside one another:

. webuse nhanes2b, clear

. svyset psuid [pweight=finalwgt], strata(stratid)

      pweight: finalwgt
          VCE: linearized
  Single unit: missing
     Strata 1: stratid
         SU 1: psuid
        FPC 1: <zero>

. estpost svy: tabulate race diabetes, row percent
(running tabulate on estimation sample)

Number of strata   =        31                Number of obs     =       10,349
Number of PSUs     =        62                Population size   =  117,131,111
                                              Design df         =           31

-------------------------------
1=white,  |  diabetes, 1=yes,  
2=black,  |        0=no        
3=other   |     0      1  Total
----------+--------------------
    White |  96.8  3.195    100
    Black |  94.1  5.903    100
    Other | 97.97  2.034    100
          | 
    Total | 96.58  3.425    100
-------------------------------
  Key:  row percentage

  Pearson:
    Uncorrected   chi2(2)         =   21.3483
    Design-based  F(1.52, 47.26)  =   15.0056     P = 0.0000

saved vectors:
             e(b) =  row percentages
            e(se) =  standard errors of row percentages
            e(lb) =  lower 95% confidence bounds for row percentages
            e(ub) =  upper 95% confidence bounds for row percentages
          e(deff) =  deff for variances of row percentages
          e(deft) =  deft for variances of row percentages
          e(cell) =  cell percentages
           e(row) =  row percentages
           e(col) =  column percentages
         e(count) =  weighted counts
           e(obs) =  number of observations

. esttab ., se nostar nostar unstack

---------------------------------------------------
                      (1)                          
                    Ratio                          
                        0            1        Total
---------------------------------------------------
White               96.80        3.195          100
                  (0.197)      (0.197)             

Black               94.10        5.903          100
                  (0.614)      (0.614)             

Other               97.97        2.034          100
                  (0.764)      (0.764)             

Total               96.58        3.425          100
                  (0.181)      (0.181)             
---------------------------------------------------
N                   10349                          
---------------------------------------------------
Standard errors in parentheses

[do-file]

If the value labels are too long or contain unsuitable characters, they are stored in macros e(labels) (row labels) and e(eqlabels) (column labels). Type varlabels(`e(labels)') and eqlabels(`e(eqlabels)') to use these labels in esttab or estout:

. label define race 1 "Race: White" 2 "Race: Black" 3 "Race: Other", modify

. label define diabetes 0 "no diab." 1 "diabetes"

. label values diabetes diabetes

. estpost svy: tabulate race diabetes, row percent
(running tabulate on estimation sample)

Number of strata   =        31                Number of obs     =       10,349
Number of PSUs     =        62                Population size   =  117,131,111
                                              Design df         =           31

----------------------------------------
1=white,  |
2=black,  |    diabetes, 1=yes, 0=no    
3=other   | no diab,  diabetes     Total
----------+-----------------------------
 Race; Wh |     96.8     3.195       100
 Race; Bl |     94.1     5.903       100
 Race; Ot |    97.97     2.034       100
          | 
    Total |    96.58     3.425       100
----------------------------------------
  Key:  row percentage

  Pearson:
    Uncorrected   chi2(2)         =   21.3483
    Design-based  F(1.52, 47.26)  =   15.0056     P = 0.0000

saved vectors:
             e(b) =  row percentages
            e(se) =  standard errors of row percentages
            e(lb) =  lower 95% confidence bounds for row percentages
            e(ub) =  upper 95% confidence bounds for row percentages
          e(deff) =  deff for variances of row percentages
          e(deft) =  deft for variances of row percentages
          e(cell) =  cell percentages
           e(row) =  row percentages
           e(col) =  column percentages
         e(count) =  weighted counts
           e(obs) =  number of observations

row labels saved in macro e(labels)
column labels saved in macro e(eqlabels)

. esttab ., se nostar nostar unstack ///
>     varlabels(`e(labels)') eqlabels(`e(eqlabels)')

---------------------------------------------------
                      (1)                          
                    Ratio                          
                 no diab.     diabetes        Total
---------------------------------------------------
Race: White         96.80        3.195          100
                  (0.197)      (0.197)             
Race: Black         94.10        5.903          100
                  (0.614)      (0.614)             
Race: Other         97.97        2.034          100
                  (0.764)      (0.764)             
Total               96.58        3.425          100
                  (0.181)      (0.181)             
---------------------------------------------------
N                   10349                          
---------------------------------------------------
Standard errors in parentheses

[do-file]

Post correlation coefficients (correlate)

By default, estpost correlate posts a vector of correlations between the first specified variable and the remaining variables. Example:

. sysuse auto
(1978 Automobile Data)

. estpost correlate price turn foreign rep78

       price |      e(b)     e(rho)       e(p)   e(count) 
-------------+--------------------------------------------
        turn |  .3096174   .3096174   .0072662         74 
     foreign |  .0487195   .0487195   .6801851         74 
       rep78 |  .0065533   .0065533     .95738         69 

. esttab, cell("rho p count") noobs

---------------------------------------------------
                      (1)                          
                    price                          
                      rho            p        count
---------------------------------------------------
turn             .3096174     .0072662           74
foreign          .0487195     .6801851           74
rep78            .0065533       .95738           69
---------------------------------------------------

[do-file]

Alternatively, specify the matrix option to post a correlation matrix. The columns of the matrix are stored in separate equations. Hence, use the unstack option in esttab or estout to print the matrix:

. sysuse auto
(1978 Automobile Data)

. estpost correlate price turn foreign rep78, matrix listwise

             |      e(b)     e(rho)       e(p)   e(count) 
-------------+--------------------------------------------
price        |                                            
       price |         1          1                    69 
        turn |  .3302013   .3302013   .0055897         69 
     foreign | -.0173639  -.0173639   .8873872         69 
       rep78 |  .0065533   .0065533     .95738         69 
turn         |                                            
        turn |         1          1                    69 
     foreign |  -.676836   -.676836   1.72e-10         69 
       rep78 | -.4961308  -.4961308   .0000146         69 
foreign      |                                            
     foreign |         1          1                    69 
       rep78 |  .5922369   .5922369   8.31e-08         69 
rep78        |                                            
       rep78 |         1          1                    69 

. esttab, unstack not noobs compress

--------------------------------------------------------------
                 (1)                                          
                                                              
               price         turn      foreign        rep78   
--------------------------------------------------------------
price              1                                          
turn           0.330**          1                             
foreign      -0.0174       -0.677***         1                
rep78        0.00655       -0.496***     0.592***         1   
--------------------------------------------------------------
* p<0.05, ** p<0.01, *** p<0.001

[do-file]

(Also see "More on correlation coefficients" under "Advanced Examples".)

Post confidence intervals for means, proportions, or counts (ci)

estpost ci posts standard errors and confidence intervals for means, proportions or counts. Example:

. sysuse auto
(1978 Automobile Data)

. estpost ci price mpg rep78, listwise
(confidence level is 95%)

             |      e(b)   e(count)      e(se)      e(lb)      e(ub) 
-------------+-------------------------------------------------------
       price |  6146.043         69   350.6166   5446.399   6845.688 
         mpg |  21.28986         69   .7062326   19.88059   22.69912 
       rep78 |  3.405797         69   .1191738   3.167989   3.643605 

. esttab, cells("b se lb ub") label

------------------------------------------------------------------------
                              (1)                                       
                                                                        
                                b           se           lb           ub
------------------------------------------------------------------------
Price                    6146.043     350.6166     5446.399     6845.688
Mileage (mpg)            21.28986     .7062326     19.88059     22.69912
Repair Record 1978       3.405797     .1191738     3.167989     3.643605
------------------------------------------------------------------------
Observations                   69                                       
------------------------------------------------------------------------

[do-file]

e(lb) and e(ub) contain the the lower and upper bounds of the confidence intervals. The default confidence level is 95% or as set by set level. To post confidence intervals using another level, apply the level() option:

. sysuse auto
(1978 Automobile Data)

. estpost ci price mpg rep78, listwise level(90)
(confidence level is 90%)

             |      e(b)   e(count)      e(se)      e(lb)      e(ub) 
-------------+-------------------------------------------------------
       price |  6146.043         69   350.6166   5561.365   6730.722 
         mpg |  21.28986         69   .7062326   20.11216   22.46755 
       rep78 |  3.405797         69   .1191738   3.207066   3.604528 

. esttab, cells("b se lb ub") label scalars(level)

------------------------------------------------------------------------
                              (1)                                       
                                                                        
                                b           se           lb           ub
------------------------------------------------------------------------
Price                    6146.043     350.6166     5561.365     6730.722
Mileage (mpg)            21.28986     .7062326     20.11216     22.46755
Repair Record 1978       3.405797     .1191738     3.207066     3.604528
------------------------------------------------------------------------
Observations                   69                                       
level                          90                                       
------------------------------------------------------------------------

[do-file]

Example with confidence intervals for proportions:

. sysuse auto
(1978 Automobile Data)

. eststo exact: estpost ci foreign, binomial exact
(confidence level is 95%)

             |      e(b)   e(count)      e(se)      e(lb)      e(ub) 
-------------+-------------------------------------------------------
     foreign |  .2972973         74   .0531331    .196584   .4148353 

. eststo agresti: estpost ci foreign, binomial agresti
(confidence level is 95%)

             |      e(b)   e(count)      e(se)      e(lb)      e(ub) 
-------------+-------------------------------------------------------
     foreign |  .2972973         74   .0531331    .204807   .4097942 

. esttab, cells(lb ub) mtitles

--------------------------------------
                      (1)          (2)
                    exact      agresti
                    lb/ub        lb/ub
--------------------------------------
foreign           .196584      .204807
                 .4148353     .4097942
--------------------------------------
N                      74           74
--------------------------------------

. eststo clear

[do-file]

Post confidence intervals for survival time (stci)

estpost stci posts confidence intervals for means and percentiles of survival time. The default is to use the median (50% percentile). Example:

. webuse page2

. estpost stci
(confidence level is 95%)

             |  e(count)     e(p50)      e(se)      e(lb)      e(ub) 
-------------+-------------------------------------------------------
       total |        40        232   2.562933        213        239 

. esttab, cell("count p50 se lb ub") noobs compress

------------------------------------------------------------
                 (1)                                        
                                                            
               count       p50        se        lb        ub
------------------------------------------------------------
total             40       232  2.562933       213       239
------------------------------------------------------------

[do-file]

To compute the statistics by subgroups, apply the by() option:

. webuse page2

. estpost stci, by(group)
(confidence level is 95%)

             |  e(count)     e(p50)      e(se)      e(lb)      e(ub) 
-------------+-------------------------------------------------------
           1 |        19        216   7.661029        190        234 
           2 |        21        233   3.081611        232        280 
-------------+-------------------------------------------------------
       total |        40        232   2.562933        213        239 

. esttab, cell("count p50 se lb ub") noobs compress ///
>     varlabels(, blist(total "{hline @width}{break}"))

------------------------------------------------------------
                 (1)                                        
                                                            
               count       p50        se        lb        ub
------------------------------------------------------------
1                 19       216  7.661029       190       234
2                 21       233  3.081611       232       280
------------------------------------------------------------
total             40       232  2.562933       213       239
------------------------------------------------------------

[do-file]

Post results from margins

estpost margins posts results from the margins command. The following example illustrates how to plot logit coefficients along with average marginal effects:

. sysuse auto, clear
(1978 Automobile Data)

. logit foreign turn weight mpg, nolog

Logistic regression                               Number of obs   =         74
                                                  LR chi2(3)      =      43.00
                                                  Prob > chi2     =     0.0000
Log likelihood = -23.535653                       Pseudo R2       =     0.4774

------------------------------------------------------------------------------
     foreign |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
        turn |  -.3992939   .1634497    -2.44   0.015    -.7196494   -.0789384
      weight |  -.0023879   .0011789    -2.03   0.043    -.0046985   -.0000773
         mpg |   -.179312   .0937591    -1.91   0.056    -.3630766    .0044525
       _cons |   24.85926   6.718033     3.70   0.000     11.69216    38.02636
------------------------------------------------------------------------------

. eststo logodds

. estpost margins, dydx(*)
Warning: cannot perform check for estimable functions.

Average marginal effects                        Number of obs     =         74
Model VCE    : OIM

Expression   : Pr(foreign), predict()
dy/dx w.r.t. : turn weight mpg

------------------------------------------------------------------------------
             |            Delta-method
             |      dy/dx   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
        turn |  -.0397669   .0133136    -2.99   0.003    -.0658612   -.0136726
      weight |  -.0002378   .0001042    -2.28   0.022     -.000442   -.0000336
         mpg |  -.0178582   .0082448    -2.17   0.030    -.0340177   -.0016988
------------------------------------------------------------------------------

. eststo AMEs

. esttab logodds AMEs, mtitles

--------------------------------------------
                      (1)             (2)   
                  logodds            AMEs   
--------------------------------------------
turn               -0.399*        -0.0398** 
                  (-2.44)         (-2.99)   

weight           -0.00239*      -0.000238*  
                  (-2.03)         (-2.28)   

mpg                -0.179         -0.0179*  
                  (-1.91)         (-2.17)   

_cons               24.86***                
                   (3.70)                   
--------------------------------------------
N                      74              74   
--------------------------------------------
t statistics in parentheses
* p<0.05, ** p<0.01, *** p<0.001

[do-file]

Note that in many cases estpost margins is not needed as you can specify margins with the post option to store results from margins in e():

. sysuse auto, clear
(1978 Automobile Data)

. logit foreign turn weight mpg, nolog

Logistic regression                               Number of obs   =         74
                                                  LR chi2(3)      =      43.00
                                                  Prob > chi2     =     0.0000
Log likelihood = -23.535653                       Pseudo R2       =     0.4774

------------------------------------------------------------------------------
     foreign |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
        turn |  -.3992939   .1634497    -2.44   0.015    -.7196494   -.0789384
      weight |  -.0023879   .0011789    -2.03   0.043    -.0046985   -.0000773
         mpg |   -.179312   .0937591    -1.91   0.056    -.3630766    .0044525
       _cons |   24.85926   6.718033     3.70   0.000     11.69216    38.02636
------------------------------------------------------------------------------

. eststo logodds

. margins, dydx(*) post
Warning: cannot perform check for estimable functions.

Average marginal effects                        Number of obs     =         74
Model VCE    : OIM

Expression   : Pr(foreign), predict()
dy/dx w.r.t. : turn weight mpg

------------------------------------------------------------------------------
             |            Delta-method
             |      dy/dx   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
        turn |  -.0397669   .0133136    -2.99   0.003    -.0658612   -.0136726
      weight |  -.0002378   .0001042    -2.28   0.022     -.000442   -.0000336
         mpg |  -.0178582   .0082448    -2.17   0.030    -.0340177   -.0016988
------------------------------------------------------------------------------

. eststo AMEs

. esttab logodds AMEs, mtitles

--------------------------------------------
                      (1)             (2)   
                  logodds            AMEs   
--------------------------------------------
turn               -0.399*        -0.0398** 
                  (-2.44)         (-2.99)   

weight           -0.00239*      -0.000238*  
                  (-2.03)         (-2.28)   

mpg                -0.179         -0.0179*  
                  (-1.91)         (-2.17)   

_cons               24.86***                
                   (3.70)                   
--------------------------------------------
N                      74              74   
--------------------------------------------
t statistics in parentheses
* p<0.05, ** p<0.01, *** p<0.001

[do-file]

Furthermore, see estadd margins if you want to add results from margins to an existing model without replacing the original coefficients.