I have several models with (three-way) interactions terms, some of them are manually coded. I am searching for a way to display regression coefficients that basically represent the same variable combination next to each other (atm I am trying this with esttab, perhaps there is another approach to achieve this). I found that the essential point is to access how Stata labels estimates in the background and to change this. I accessed a matrix of estimates and made some changes to its column names. Via erepost I substituted new column names. Still this approach is only working for continuous variables. Dummy or factor variable seem to be coded in a very different way. It would be so great to see corresponding coefficients next to each other.

Thank you so much.
Code:
// data sysuse auto, clear // interaction model 1 regress price c.mpg##c.mpg##foreign estimates store interaction1 // interaction model 2 gen mpg_mpg_foreign = mpg*mpg*foreign gen mpg_mpg = mpg*mpg gen mpg_foreign = mpg*foreign regress price mpg mpg_mpg foreign mpg_foreign mpg_mpg_foreign * store estimation results in matrix b mat b=e(b) * access all colnames in the matrix b local colnames: colnames b * substitute particular string in colnames list local colnames : subinstr local colnames "mpg_mpg" "c.mpg#c.mpg", all local colnames : subinstr local colnames "mpg_foreign" "foreign#c.mpg", all * local colnames : subinstr local colnames "foreign " "1.foreign", all * rename matrix colnames with new local list matrix colname b = `colnames' * replace all estimates with erepost package capt prog drop replace_b program replace_b, eclass erepost b= b, rename end replace_b estimates store interaction2 // make table esttab interaction1 interaction2, nobaselevels esttab interaction1 interaction2, nobaselevels label
Thank you so much.
Comment