Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: st: Marginal effects with outreg or estout using the new margins command
From
John Luke Gallup <[email protected]>
To
[email protected]
Subject
Re: st: Marginal effects with outreg or estout using the new margins command
Date
Tue, 30 Jul 2013 22:45:27 +0200
Danielle,
Putting both the coefficient estimates and the marginal effects in the same table is straightforward using -outreg- (which is a different program than -outreg2-, and more recently updated). Both programs are user-written programs on SSC.
It is just necessary to include the statistics in the -stat- option:
sysuse auto, clear
areg mpg length [aweight=weight], cluster(rep78) absorb(rep78)
margins, eyex(length) atmeans
outreg, stat(b se b_dfdx se_dfdx) bdec(3) nocons
The resulting table is
---------------------
mpg
---------------------
length -0.187
(0.029)**
[-1.809]
<0.277>
R2 0.68
N 69
---------------------
* p<0.05; ** p<0.01
You can make it look exactly like the table below using the -rtitles- and -bracket- options.
John
On Jul 27, 2013, at 6:08 PM, Danielle Li <[email protected]> wrote:
> Yes, that works perfectly. Federico, thank you!
>
> Quick followup--is there a way to get it to output both the
> coefficient estimates and the marginal effects to be below one
> another? e.g.
>
> (1)
> Main coeff 1 1.3
> (0.5)
> Elasticity 1 0.6
> (.03)
>
> Main coeff 2 1.7
> (0.8)
> Elasticity 2 0.4
> (.02)
>
> Thanks again,
> Danielle
>
>
> On Sat, Jul 27, 2013 at 11:46 AM, Federico Belotti <[email protected]> wrote:
>> Danielle
>> try to add the option -post- to the -margin- command...
>>
>> Federico
>>
>> Il giorno 27/lug/2013, alle ore 17:33, Danielle Li <[email protected]> ha scritto:
>>
>>> Dear all,
>>>
>>> I'd like to output marginal effects from a fixed effects regression.
>>> I have tried 4 approaches involving the outreg2, estout, mfx, and
>>> margins commands and none of them work (described below).
>>>
>>> I would be really grateful if anyone has any ideas. Ideally, I'd to
>>> report both the coefficients and the marginal effects in the same
>>> output table, but I am also happy to just output the marginal effects
>>> and coefficients into separate tables and combine later.
>>>
>>> Thanks so much,
>>> Danielle
>>>
>>>
>>>
>>> 1. Using margins with outreg2
>>>
>>> areg y x [aweight=weight], cluster(is) absorb(is)
>>> margins, eyex(x) atmeans
>>> outreg2 x using filename, se nolabel bdec(3) rdec(3) nocons excel
>>> replace margin
>>>
>>> This command runs without error but when I look at my outreg file,
>>> there are no coefficients reported (e.g. the space where the result is
>>> is just blank)
>>>
>>> 2. Using mfx instead of margins
>>>
>>> areg y x [aweight=weight], cluster(is) absorb(is)
>>> mfx, eyex predict
>>> outreg2 x using filename, se nolabel bdec(3) rdec(3) excel replace mfx
>>>
>>> This fails because I get this error using mfx
>>>
>>> mfx, eyex
>>> default predict() is unsuitable for marginal-effect calculation
>>> r(119)
>>>
>>> Note: any predict option I explicitly try results in the same error.
>>>
>>> 3. Using estout with margins
>>>
>>> eststo raw: areg y x [aweight=weight], cluster(is) absorb(is)
>>> eststo mfx: margins, eyex(x) atmeans
>>> estout raw mfx using filename, replace
>>>
>>> This runs without error, but eststo raw and eststo mfx end up saving
>>> the same output even though, when I run the margins, command, stata
>>> successfully reports elasticities that are different from the
>>> coefficients in the areg step. So I get two columns with the same
>>> information.
>>>
>>> 4. All of the above with xtreg instead of areg. I get the same error
>>> *
>>> * For searches and help try:
>>> * http://www.stata.com/help.cgi?search
>>> * http://www.stata.com/support/faqs/resources/statalist-faq/
>>> * http://www.ats.ucla.edu/stat/stata/
>>
>> *
>> * For searches and help try:
>> * http://www.stata.com/help.cgi?search
>> * http://www.stata.com/support/faqs/resources/statalist-faq/
>> * http://www.ats.ucla.edu/stat/stata/
> *
> * For searches and help try:
> * http://www.stata.com/help.cgi?search
> * http://www.stata.com/support/faqs/resources/statalist-faq/
> * http://www.ats.ucla.edu/stat/stata/
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/faqs/resources/statalist-faq/
* http://www.ats.ucla.edu/stat/stata/