Bookmark and Share

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: Outreg for asclogit


From   Wameq Raza <[email protected]>
To   [email protected]
Subject   Re: st: Outreg for asclogit
Date   Wed, 3 Oct 2012 11:31:09 +0200

Hi John,
Thank you yet again for coming through! I'll give this a shot and let
you know how it goes.
Best
Wameq

On Wed, Oct 3, 2012 at 6:39 AM, John Luke Gallup <[email protected]> wrote:
> Wameq,
>
> -outreg- (and probably -outreg2- and -estout-) don't handle marginal effects after -asclogit- because the results are saved in a very non-standard format.
>
> -estat mfx-, which is only for use after -asclogit- saves the marginal effects in r() matrices named after the logit categories.
>
> Things you can't do in -outreg- you can still do with a bit of work with -frmttable-, which is the formatting engine distributed with -outreg-.
>
> The following code creates an -outreg- compatible table (which can be merged, etc.) showing the marginal effects with t-statistics below them and asterisks for significance.
>
> First I calculate the marginal effects:
>
> webuse choice, clear
> asclogit choice dealer, case(id) alternatives(car) casevars(sex income)
> estat mfx, at(sex=0 dealer=1)
>
> Then I create a Stata matrix holding the marginal effects and t-stats (`b') and an indicator matrix for where the stars go (`stars', using the mata command).  These are passed to -frmttable- to create a Word table (or TeX table) with the results.
>
> tempname b stars
> loc ctitl `""","""'
> forvalues i = 1/`e(k_alt)' {
>         tempname b`i'
>         mat `b`i'' = r(`e(alt`i')')
>         mat `b' = (nullmat(`b'), `b`i''[.,1..1], `b`i''[.,3..3])
>         mat `stars' = (nullmat(`stars'), `b`i''[.,4..4])
>         loc ctitl `"`ctitl' ,`e(alt`i')'"'
> }
> mata: st_matrix("`stars'", (abs(st_matrix("`stars'")):<0.05) + ///
>         (abs(st_matrix("`stars'")):<0.01))
> frmttable using ascmfx, statmat(`b') substat(1) ///
>         annotate(`stars') asymbol("*","**") ctitle(`ctitl') ///
>         replace note("* p<0.05; ** p<0.01")
>
> You could adapt this to report standard errors, p-values, or change the stars, etc. if you want.
> Here's the table:
>
>                                         ---------------------------------------------------
>                                                               American   Japan    Europe
>                                         ---------------------------------------------------
>                                          dealer    American     0.02*     -0.01    -0.00
>                                                                (2.29)*   (-2.34)  (-1.66)
>                                                    Japan       -0.01*     0.02     -0.00
>                                                                (-2.34)   (1.83)   (-1.03)
>                                                    Europe       -0.00     -0.00    0.01
>                                                                (-1.66)   (-1.03)  (1.30)
>                                          casevars  sex*         0.03      -0.16    0.13
>                                                                (0.38)*   (-2.03)  (1.76)
>                                                    income      -0.01**    0.01     0.00
>                                                                (-2.95)   (1.96)   (1.14)
>                                         ---------------------------------------------------
>                                                         * p<0.05; ** p<0.01
>
>
> John
>
>
> On Oct 2, 2012, at 1:38 PM, Wameq Raza <[email protected]> wrote:
>
>> Hi everyone,
>> I was wondering if anyone could kindly tell me if there's a way to get
>> the marginal effects of a asclogit model that I'm running
>> into a table using outreg.
>> More specifically, I'm generating the marginal effects using: estat
>> mfx, var (variables); i'm doing this for both alt specific and
>> case specific vars.
>> Any help would be much appreciated!
>> Best
>> Wameq
>>
>> --
>> W A M E Q   R A Z A
>> *
>> *   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/



-- 
W A M E Q   R A Z A
*
*   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/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index