Hello all,
I am trying to generate a regression table with an additional column of customized contents (average of coefficients across different regression columns) using estout/esttab.
The purpose is to show the average impact across industries.
I could generate a matrix of mean coefficients, but I am having trouble combining the mean matrix and existing regression tables using esttab command.
I am attaching an example code below:
TT is the mean matrix, and I would like to generate a regression table using something like "esttab TT M1 M2 M3 M4 M5".
(I need to keep the number of observations and will be exporting the regression table to Latex.)
Any help would be greatly appreciated.
Thank you.
I am trying to generate a regression table with an additional column of customized contents (average of coefficients across different regression columns) using estout/esttab.
The purpose is to show the average impact across industries.
I could generate a matrix of mean coefficients, but I am having trouble combining the mean matrix and existing regression tables using esttab command.
I am attaching an example code below:
TT is the mean matrix, and I would like to generate a regression table using something like "esttab TT M1 M2 M3 M4 M5".
(I need to keep the number of observations and will be exporting the regression table to Latex.)
Code:
clear all
cls all
sysuse auto, clear
reg price weight length
mat TT =e(b)
mat list TT
mat TT[1,1] = 0
mat TT[1,2] = 0
mat TT[1,3] = 0
mat list TT
tostring rep78, replace
drop if rep78=="."
levelsof rep78, local(c)
foreach i of local c {
eststo M`i': reg price weight length if rep78 =="`i'"
matrix B_`i'=e(b)
mat TT[1,1]= TT[1,1] + B_`i'[1,1]
mat TT[1,2]= TT[1,2] + B_`i'[1,2]
mat TT[1,3]= TT[1,3] + B_`i'[1,3]
}
* Mean of coefficients
mat TT[1,1] = TT[1,1]/5
mat TT[1,2] = TT[1,2]/5
mat TT[1,3] = TT[1,3]/5
mat list TT
esttab M1 M2 M3 M4 M5, stats(N, fmt(%9.0fc) ///
labels(`"Observations"'))
Any help would be greatly appreciated.
Thank you.

Comment