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

How to match coefficients across models for single term and interaction term #62

Closed fredericky123 closed 10 months ago

fredericky123 commented 10 months ago
sysuse auto,clear
set seed 123
generate altmpg = invnorm(uniform())
eststo clear
eststo: quietly regress price c.weight##c.mpg
eststo: quietly regress price c.weight##c.altmpg
esttab
esttab, rename(altmpg "Mpg" mpg "Mpg")
image

In the example, the interaction term did't be matched, how to set all coefficients of "mpg" and "altmpg" be matched? If I have ten models, I want the alternative "mpg" (inbckuding its interction terms) to be output in the same cell, how to set this? In other way, can we rename a list of varlables in a batch so that the list of varables will be renamed (including the single term and interaction term)

benjann commented 10 months ago

Option rename() operates at the level of individual coefficients, not variables. You need to rename each coefficient individually. In your case you could type

esttab, rename(altmpg mpg c.weight#c.altmpg c.weight#c.mpg)

ben

fredericky123 commented 10 months ago

Thanks Ben! Is that possible to use the option "varlabels" to rename each variables and stack the variables with the same label to one cell?

benjann commented 10 months ago

Nope. varlabels() only assigns labels, it does not affect how results will be arranged.

fredericky123 commented 10 months ago

I see. I have a list of variables to be renamed when output about 10 models into a table. Look forward an option that can make "rename" more efficiently. Thanks!