benjann / estout

Stata module to make regression tables
http://repec.sowi.unibe.ch/stata/estout/index.html
MIT License
71 stars 18 forks source link

[bug] esttab ommit the beta coefficient for interaction term #64

Open fredericky123 opened 2 months ago

fredericky123 commented 2 months ago
sysuse auto,clear
eststo:  regress price weight c.mpg##i.foreign,beta
esttab ., beta
image

The output of beta coefficient for the interaction are omitted

benjann commented 2 months ago

Option beta in esttab calls estadd beta, which has been written long before Stata had factor variables and does not work with interactions. However, since regress nowadays stores the beta coefficients in e(beta) you can simply read the values from there. Example:

. clear all
. sysuse auto
. regress price weight c.mpg##i.foreign,beta
. esttab, main(beta) nobase drop(_cons)

----------------------------
                      (1)   
                    price   
----------------------------
weight              1.216***
                   (6.36)   

mpg                 0.516*  
                   (2.38)   

1.foreign           1.754***
                   (4.08)   

1.foreign#~g       -1.244** 
                  (-2.83)   
----------------------------
N                      74   
----------------------------
beta coefficients; t statistics in parentheses
* p<0.05, ** p<0.01, *** p<0.001

or

. estout, cells(beta)

-------------------------
                        .
                     beta
-------------------------
weight           1.215683
mpg              .5162482
0.foreign               0
1.foreign        1.753747
0.foreign#~g            0
1.foreign#~g    -1.243539
-------------------------

ben

fredericky123 commented 2 months ago

Thanks! However, I used the command reghdfe, I hope there will be one day esttab also support the interaction

sergiocorreia commented 2 months ago

If reghdfe is missing an e() matrix it should be pretty easy to add btw

fredericky123 commented 2 months ago
sysuse auto,clear
eststo:  reghdfe price weight c.mpg##i.foreign,
esttab ., beta

Could you please give me an example