bill999
bill999

Reputation: 2560

How to add text to bottom of esttab table without using estadd

The code below adds custom text to each equation using a local and produces what I want:

estimates clear
eststo clear
sysuse auto, clear

eststo w1: regress price mpg trunk length
estadd local number one
eststo w2: regress turn mpg trunk length
estadd local number two
eststo w3: regress displacement mpg trunk length
estadd local number three

esttab w1 w2 w3, stats(number)

However, I would like to be able to write the custom text in the esttab command syntax and not before using locals.

This is incorrect, but the option might look something like the following:

estimates clear
eststo clear
sysuse auto, clear

eststo w1: regress price mpg trunk length
eststo w2: regress turn mpg trunk length
eststo w3: regress displacement mpg trunk length

esttab w1 w2 w3, stats("number", "one" "two" "three")

Can I somehow insert an option to the esttab command where I spell out what I want? I know that there is an indicate() option, but I could not figure out if it can do what I need or not.

Upvotes: 1

Views: 2204

Answers (1)

user8682794
user8682794

Reputation:

Unfortunately, you cannot define the contents of a stats() element on the fly.

However, a workaround is the following:

sysuse auto, clear
eststo clear
estimates clear

eststo w1: regress price mpg trunk length
eststo w2: regress turn mpg trunk length
eststo w3: regress displacement mpg trunk length

esttab, prefoot(`"{hline 60}"' ///
                `"numbers{dup 15: }one{dup 13: }two{dup 11: }three"' ///
                `"more numbers{dup 9: }four{dup 12: }five{dup 13: }six"') 

------------------------------------------------------------
                      (1)             (2)             (3)   
                    price            turn    displacement   
------------------------------------------------------------
mpg                -173.7         -0.0656          -1.777   
                  (-1.97)         (-0.88)         (-1.04)   

trunk              -0.855         -0.0593          0.0659   
                  (-0.01)         (-0.66)          (0.03)   

length              21.40           0.165***        3.068***
                   (0.79)          (7.19)          (5.83)   

_cons              5854.0           10.76*         -342.3** 
                   (0.97)          (2.09)         (-2.92)   
------------------------------------------------------------
numbers               one             two           three
more numbers         four            five             six
N                      74              74              74   
------------------------------------------------------------
t statistics in parentheses
* p<0.05, ** p<0.01, *** p<0.001

Obviously, you will have to specify every time the spaces according to your use case. You can do this manually or by writing a small program that calculates these.

Upvotes: 4

Related Questions