Closed sergiocorreia closed 9 years ago
As requested by email: I do it manually with esttab, scalars()
.
eststo: reghdfe y x, a(stratum) vce(cl stratum)
estadd local stratum_fe "{Yes}"
esttab, scalars("stratum_fe Stratum FE")
@NilsEnevoldsen But doesn't that places the FE below the line instead of before the line, right where _cons would be?
Yes, it does. I think it would be better to place it above the line, as you suggest.
I cannot offer a change to estout
so that it picks up such command specific stuff. However, here's a trick how to get the indicators above the line, using erepost
from SSC:
sysuse auto
regress price weight
eststo m1
areg price weight, a(foreign)
mat b = 0
mat coln b = _fe
mat b = e(b), b
mat V = e(V)
mat V = (V, J(rowsof(V), 1, 0)) \ (J(1, colsof(V), 0), 0)
erepost b=b V=V, rename
eststo m2
esttab, indicate(_fe)
That is, simply add an extra coefficient to the coefficient vector. This can be easily turned into a program:
program addfe
if `"`0'"'=="" local 0 _fe
tempname b V
mat `b' = 0
mat coln `b' = `0'
mat `b' = e(b), `b'
mat `V' = e(V)
mat `V' = (`V', J(rowsof(`V'), 1, 0)) \ (J(1, colsof(`V'), 0), 0)
erepost b=`b' V=`V', rename
end
sysuse auto
regress price weight
addfe fe1
eststo m1
areg price weight, a(foreign)
addfe fe1
addfe fe2
eststo m2
esttab, indicate(fe1 fe2)
Furthermore, you could make such a program responsive to what's in your model (such as e(absvar)
). Of course, such modifications should only be made for purpose of tabulation, that is, you'd want to hold on to the original results and maybe trash the modified ones after tabulation:
sysuse auto
areg price weight, a(foreign)
eststo original
addfe
eststo modified
esttab modified, indicate(_fe)
est drop modified
est restore original
areg
That's a really neat trick!
Thanks, Sergio
By the way, there is a subtle "bug" in erepost (in quotes because it's not strictly a bug):
Since it uses version 8, it doesn't allow me to add new rows or columns with interaction terms.
Maybe a line like this can work?
local version `clip(`c(version)', 8, 13)'
version `version'
That would match version to e.g. 13 if I have 13, but if someone else has version 8 it would do 8. I do this but since I don't have Stata 8 I don't know if c(version) already existed by then (perhaps not).
Best, S
Example:
sysuse auto
reg price weight
matrix b = e(b)
matrix colnames b = "a#b"
matrix V = e(V)
erepost b=b, rename
Error:
a#c: operator invalid
r(198);
By the way, and in case it's useful for you @NilsEnevoldsen , I wrote the wrapper.
The end of the file has a detailed example, but in its simple form, you just do
estfe * , labels(stratum_fe "Stratum FE")
esttab * , indicate(`r(indicate_fe)')
estfe *, restore
You don't have to specify labels but it looks nicer. It's also general (supports areg), allows sorting (based on the order in labels()
), and you can still use indicate
for other stuff like controls.
Anyways, if you use it remember to patch erepost.ado (SSC) by removing the version
line.
I now fixed erepost
to be compatible with factor variable notation. I sent the update to Kit Baum for upload to the SSC Archive. I also uploaded to package to github: https://github.com/benjann/erepost
Other than suggested by Sergio I did not change the version
statement. I just use a different method to copy the column names that is not version dependent (lines 84-87 in the code).
Thanks! Sergio
Neat. Thanks to both of you.
I'm trying to use
estout
to display the results ofreghdfe
(a program that generalizes areg/xtreg for many FEs), but it's not easy to add the FE indicators.I'm looking at the internals of
ProcessIndicateGrp
andParseIndicateOpts
but I can't find an easy way to hack it from the outside to allow showing yes/no for a set of fixed effects.Have you thought about allowing fixed effects from an
e(absvar)
string? For instance, if e(absvar)=="firm industry#year" that means there are two sets of fixed effects. Since I wrote reghdfe I can change it and add hidden e() stuff to make it easier to you to parse it, but I don't know what would you need and if it is feasible (given that the estout internals already look quite complex)Best, Sergio