Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to stack two different regression tables into one single regression table?

    I hope everyone is doing well. I wish to stack two regression tables in a single regression table. I'm making an example using auto data. Can someone please comment if this is possible in stata?

    Example:

    sysuse auto, clear

    eststo reg1: regress price mpg rep78
    esttab reg1 using "Table-1.rtf"

    eststo reg2: regress weight length
    esttab reg2 using "Table-2.rtf"

    Now this will make two different tables for the regressions. What I want is to make a table where the estimates of these two are stacked vertically.
    Last edited by Danish Naeem Khan; 11 May 2022, 10:20.

  • #2
    Use a single esttab command and tell it the names of both stored models. In the example below I commented out the using so the table with two models would appear in the log.
    Code:
    . sysuse auto, clear
    (1978 automobile data)
    
    . 
    . eststo reg1: regress price mpg rep78
    
          Source |       SS           df       MS      Number of obs   =        69
    -------------+----------------------------------   F(2, 66)        =     11.06
           Model |   144754063         2  72377031.7   Prob > F        =    0.0001
        Residual |   432042896        66  6546104.48   R-squared       =    0.2510
    -------------+----------------------------------   Adj R-squared   =    0.2283
           Total |   576796959        68  8482308.22   Root MSE        =    2558.5
    
    ------------------------------------------------------------------------------
           price | Coefficient  Std. err.      t    P>|t|     [95% conf. interval]
    -------------+----------------------------------------------------------------
             mpg |  -271.6425   57.77115    -4.70   0.000    -386.9864   -156.2987
           rep78 |   666.9568   342.3559     1.95   0.056     -16.5789    1350.492
           _cons |   9657.754    1346.54     7.17   0.000       6969.3    12346.21
    ------------------------------------------------------------------------------
    
    . eststo reg2: regress weight length
    
          Source |       SS           df       MS      Number of obs   =        74
    -------------+----------------------------------   F(1, 72)        =    613.27
           Model |  39461306.8         1  39461306.8   Prob > F        =    0.0000
        Residual |  4632871.55        72  64345.4382   R-squared       =    0.8949
    -------------+----------------------------------   Adj R-squared   =    0.8935
           Total |  44094178.4        73  604029.841   Root MSE        =    253.66
    
    ------------------------------------------------------------------------------
          weight | Coefficient  Std. err.      t    P>|t|     [95% conf. interval]
    -------------+----------------------------------------------------------------
          length |   33.01988   1.333364    24.76   0.000     30.36187    35.67789
           _cons |  -3186.047   252.3113   -12.63   0.000     -3689.02   -2683.073
    ------------------------------------------------------------------------------
    
    . esttab reg1 reg2 /* using "Table-both.rtf" */
    
    --------------------------------------------
                          (1)             (2)   
                        price          weight   
    --------------------------------------------
    mpg                -271.6***                
                      (-4.70)                   
    
    rep78               667.0                   
                       (1.95)                   
    
    length                              33.02***
                                      (24.76)   
    
    _cons              9657.8***      -3186.0***
                       (7.17)        (-12.63)   
    --------------------------------------------
    N                      69              74   
    --------------------------------------------
    t statistics in parentheses
    * p<0.05, ** p<0.01, *** p<0.001
    
    .

    Comment


    • #3
      Thank you for replying William Lisowski.

      I recently tried the following code and ended up with a table similar to yours using the following code

      Code:
      eststo reg1: reg price mpg rep78
      
      eststo reg2: reg price length weight
      esttab reg1 reg2 using "autotable.rtf", title(test table) refcat (mpg "Model-1" length "Model-2") nocons replace
      However, I want this table to look something like the one in the attachment.


      is it possible to make it look this way?
      Attached Files
      Last edited by Danish Naeem Khan; 12 May 2022, 00:48.

      Comment


      • #4
        I do not think estout is designed to produce tables where the models appear in the same two columns, stacked vertically.

        Comment

        Working...
        X