Closed fredericky123 closed 2 years ago
cells()
option with esttab
when possible. esttab
is a wrapper for estout
, and will construct the appropriate estout, cells()
call for you. In fact, you can add the option noisily
to see the exact estout
command that esttab
creates. If you add the esttab
option b(3)
with noisily
, you will see that you get estout , cells(b(fmt(3) star))
automatically. You can use cells()
if you want, but you will be overwriting some of the smarts that esttab
provides.eqlabels(,none)
. Specify eqlabels(1 2 3 4 5)
instead.corr
rather than estout
, but that doesn't appear to be an option for corr
.Like Nils indicated, the equation labels can be set as follows:
. sysuse auto, clear
. estpost corr price mpg rep78 trunk weight,matrix
. esttab ., b(3) nonumbers noobs nomtitle not nogaps unstack label compress eqlab(1 2 3 4 5)
---------------------------------------------------------------------------------
1 2 3 4 5
---------------------------------------------------------------------------------
Price 1.000
Mileage (mpg) -0.469*** 1.000
Repair reco~1978 0.007 0.402*** 1.000
Trunk spa.. ft.) 0.314** -0.582*** -0.157 1.000
Weight (lbs.) 0.539*** -0.807*** -0.400*** 0.672*** 1.000
---------------------------------------------------------------------------------
* p<0.05, ** p<0.01, *** p<0.001
To get rid of the correlations with itself you can use the drop()
option:
. esttab ., b(3) nonumbers noobs nomtitle not nogaps unstack label compress eqlab(1 2 3 4) drop(price:price mpg:mpg trunk:trunk weight:weight)
--------------------------------------------------------------------
1 2 3 4
--------------------------------------------------------------------
Mileage (mpg) -0.469***
Repair reco~1978 0.007 0.402*** 1.000
Trunk spa.. ft.) 0.314** -0.582*** -0.157
Weight (lbs.) 0.539*** -0.807*** -0.400*** 0.672***
--------------------------------------------------------------------
* p<0.05, ** p<0.01, *** p<0.001
But probably you will want to label the equations differently in this case...
Thanks @benjann ! If esttab can have an option to drop all correlations with itslef, that will be great; for the reason that usually we have a lot of control variables. listing all variables in "drop(price:price mpg:mpg trunk:trunk weight:weight)" seems to be redundant
I am reluctant to add such an option because it is very specific. My suggestion would be to use code such as the following:
. local xvars price mpg rep78 trunk weight
. sysuse auto, clear
. estpost corr `xvars', matrix
. local drop
. foreach x of local xvars {
local drop `drop' `x':`x'
}
. esttab ., b(3) nonumbers noobs nomtitle not nogaps unstack label compress eqlab(1 2 3 4) drop(`drop')
--------------------------------------------------------------------
1 2 3 4
--------------------------------------------------------------------
Mileage (mpg) -0.469***
Repair reco~1978 0.007 0.402***
Trunk spa.. ft.) 0.314** -0.582*** -0.157
Weight (lbs.) 0.539*** -0.807*** -0.400*** 0.672***
--------------------------------------------------------------------
* p<0.05, ** p<0.01, *** p<0.001
Or define a little program
capt program drop dropdiag
program dropdiag, rclass
local varlist: coln e(b)
local varlist: list uniq varlist
foreach x in `varlist' {
local drop `drop' `x':`x'
}
return local drop `"`drop'"'
end
and use it as follows:
. sysuse auto, clear
. estpost corr price mpg rep78 trunk weight, matrix
. dropdiag
. esttab ., b(3) nonumbers noobs nomtitle not nogaps unstack label compress eqlab(1 2 3 4) drop(`r(drop)')
--------------------------------------------------------------------
1 2 3 4
--------------------------------------------------------------------
Mileage (mpg) -0.469***
Repair reco~1978 0.007 0.402***
Trunk spa.. ft.) 0.314** -0.582*** -0.157
Weight (lbs.) 0.539*** -0.807*** -0.400*** 0.672***
--------------------------------------------------------------------
* p<0.05, ** p<0.01, *** p<0.001
Thanks so much, the local function is elegant enough!
I want to replace the labels of the equations to be 1, 2, and 3... how to do this?
I also want to supress the correlations 1 (the correlations of the variable itself), can we?