Announcement

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

  • Variable information in table notes using estout/esttab

    Hi,

    I am trying to format a series of regression tables with estout/esttab. My regressions all have the same sample size. Is there a way to include the sample size in the table notes / footer instead of having the same information repeated for all models?

    Is there a way to use a variable like the sample size in esttab, addnotes or estout, notes?

    See reproducible example below:

    Code:
    . 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   <- This is what I wanted to move to the table footer
    --------------------------------------------
    t statistics in parentheses
    * p<0.05, ** p<0.01, *** p<0.001

    This is what I wanted:

    Code:
    --------------------------------------------
                          (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)   
    --------------------------------------------
    Notes: N=74, t statistics in parentheses
    * p<0.05, ** p<0.01, *** p<0.001

  • #2
    Here is some code that demonstrates the basic technique and then produces the output with your particular formatting. I should note that the number of observations will be taken from the final set of estimates; nothing guarantees that the same number of observations was actually used in each regression, so this has the potential to be misleading. If I were doing this, I would confirm that the number of observations does not change. Actually, I prefer to show the number of observations in each column, because I'm often reporting other statistics with it.
    Code:
    estimates clear
    sysuse auto, clear
    eststo: quietly regress price weight mpg
    eststo: quietly regress price weight mpg foreign
    esttab, noobs addnotes(Note: N=`=e(N)')
    esttab, noobs nonotes addnotes( ///
        "{bf}Notes: N=`=e(N)',{sf} t statistics in parentheses" ///
        "* p<0.05, ** p<0.01, *** p<0.001" ///
        )
    Code:
    --------------------------------------------
                          (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)  
    --------------------------------------------
    t statistics in parentheses
    Note: N=74
    * p<0.05, ** p<0.01, *** p<0.001
    Code:
    --------------------------------------------
                          (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)  
    --------------------------------------------
    Notes: N=74, t statistics in parentheses
    * p<0.05, ** p<0.01, *** p<0.001
    Last edited by William Lisowski; 22 Apr 2019, 14:44.

    Comment

    Working...
    X