Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • The ouput of logistic regressions in a table (using outreg2, estout, asdoc, ...)

    Dear All, After running logistic regressions, how can I export the results, in terms of (1) coefficients, (2) marginal effects, and (3) odd ratios, in a table to Word file using (ssc install) outreg2? Please see the following:
    Code:
    sysuse auto, clear
    logit foreign price mpg weight, robust
    outreg2 using "logit", word dec(4) ctitle(Coefficients) replace
    Ho-Chuan (River) Huang
    Stata 17.0, MP(4)

  • #2
    For reporting marginal effects, you may kindly share a layout that is generally acceptable in research publications. For the other two points, here is the solution using asdoc / asdocx.


    Code:
     asdocx logit foreign price mpg weight, robust replace dec(4) cnames(Coefficients) nest
    
                              Table: Regression results
      0 |1                                                    2
    ----+-----------------------------------------------------------------------------
      1 |                                                   (1)
      2 |                                          Coefficients
    ----+-----------------------------------------------------------------------------
      3 |price                                        0.0009***
      4 |                                              (0.0003)
      5 |mpg                                            -0.1211
      6 |                                              (0.0851)
      7 |weight                                      -0.0068***
      8 |                                              (0.0019)
      9 |_cons                                       14.4224***
     10 |                                               (4.859)
     11 |Observations                                        74
     12 |Pseudo R2                                       0.6189
    ----------------------------------------------------------------------------------
    * Odd ratio
    Code:
     asdocx logit foreign price mpg weight, robust replace dec(4) cnames(Odd Ratios) nest eform
    
    Logistic regression                             Number of obs     =         74
                                                    Wald chi2(3)      =      14.65
                                                    Prob > chi2       =     0.0021
    Log pseudolikelihood = -17.161893               Pseudo R2         =     0.6189
    
    ------------------------------------------------------------------------------
                 |               Robust
         foreign | Odds Ratio   Std. Err.      z    P>|z|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
           price |   1.000927   .0002607     3.56   0.000     1.000416    1.001438
             mpg |   .8859526   .0754319    -1.42   0.155     .7497861    1.046848
          weight |   .9931737   .0018549    -3.67   0.000     .9895448    .9968159
           _cons |    1834670    8914573     2.97   0.003     134.1558    2.51e+10
    ------------------------------------------------------------------------------
    Note: _cons estimates baseline odds.
    
    
    
      
                                 Table: Regression results
      0 |1                                                    2
    ----+-----------------------------------------------------------------------------
      1 |                                                   (1)
      2 |                                          Odd_Ratios
    ----+-----------------------------------------------------------------------------
      3 |price                                        1.0009***
      4 |                                              (0.0003)
      5 |mpg                                              0.886
      6 |                                              (0.0754)
      7 |weight                                       0.9932***
      8 |                                              (0.0019)
      9 |_cons                                     1834669.5***
     10 |                                           (8914573.1)
     11 |Observations                                        74
     12 |Pseudo R2                                       0.6189
    ----------------------------------------------------------------------------------
    Click to Open File:  C:\temp\MyFile.docx
    Regards
    --------------------------------------------------
    Attaullah Shah, PhD.
    Professor of Finance, Institute of Management Sciences Peshawar, Pakistan
    FinTechProfessor.com
    https://asdocx.com
    Check out my asdoc program, which sends outputs to MS Word.
    For more flexibility, consider using asdocx which can send Stata outputs to MS Word, Excel, LaTeX, or HTML.

    Comment


    • #3
      Dear Attaullah, Thanks for the helpful suggestions. As you might reccall, I am a subscriber of your interesting "asdocx". The reason to ask for the report of marginal effects is that someone asked this question (here, in Chinese).
      Ho-Chuan (River) Huang
      Stata 17.0, MP(4)

      Comment


      • #4
        The above code is equally valid for asdoc. However, a table for reporting margins has always puzzled me since I have not used margins before. Therefore, if such a table / template is to be added to asdocx, I would need some standard format that is normally used in research publications.
        Regards
        --------------------------------------------------
        Attaullah Shah, PhD.
        Professor of Finance, Institute of Management Sciences Peshawar, Pakistan
        FinTechProfessor.com
        https://asdocx.com
        Check out my asdoc program, which sends outputs to MS Word.
        For more flexibility, consider using asdocx which can send Stata outputs to MS Word, Excel, LaTeX, or HTML.

        Comment


        • #5
          Dear Attaullah, Got it and thanks.

          Ho-Chuan (River) Huang
          Stata 17.0, MP(4)

          Comment


          • #6
            I added margins to asdocx. Here is a working example of creating a nested table of margins with asdocx. https://fintechprofessor.com/asdocx/...s-with-asdocx/
            The update is available in the beta version of asdocx, therefore, it can be installed with
            Code:
            asdocx_update, beta
            Last edited by Attaullah Shah; 01 Jan 2022, 01:43.
            Regards
            --------------------------------------------------
            Attaullah Shah, PhD.
            Professor of Finance, Institute of Management Sciences Peshawar, Pakistan
            FinTechProfessor.com
            https://asdocx.com
            Check out my asdoc program, which sends outputs to MS Word.
            For more flexibility, consider using asdocx which can send Stata outputs to MS Word, Excel, LaTeX, or HTML.

            Comment


            • #7
              Dear Attaullah, Thanks for the extra function. I have updated asdocx.
              Ho-Chuan (River) Huang
              Stata 17.0, MP(4)

              Comment


              • #8
                The link in #6 is shortened and not working, here is the full link https://fintechprofessor.com/asdocx/...s-with-asdocx/
                Regards
                --------------------------------------------------
                Attaullah Shah, PhD.
                Professor of Finance, Institute of Management Sciences Peshawar, Pakistan
                FinTechProfessor.com
                https://asdocx.com
                Check out my asdoc program, which sends outputs to MS Word.
                For more flexibility, consider using asdocx which can send Stata outputs to MS Word, Excel, LaTeX, or HTML.

                Comment


                • #9
                  Dear Attaullah, Got it and thanks.

                  Ho-Chuan (River) Huang
                  Stata 17.0, MP(4)

                  Comment


                  • #10
                    Dear Attaullah, I update and run the code (asdocx_update, beta) but find that
                    Code:
                    . 
                    . * add asdocx to the margin command: replace and nest option belong to asdocx
                    . asdocx margins , dydx(*) atmeans replace nest tzok 
                    
                    Conditional marginal effects                            Number of obs = 10,351
                    Model VCE: Robust
                    
                    Expression: Pr(highbp), predict()
                    dy/dx wrt:  age age2 race
                    At: age  = 47.72235 (mean)
                        age2 = 2567.122 (mean)
                        race = 1.143525 (mean)
                    
                    ------------------------------------------------------------------------------
                                 |            Delta-method
                                 |      dy/dx   std. err.      z    P>|z|     [95% conf. interval]
                    -------------+----------------------------------------------------------------
                             age |   .0193656   .0023635     8.19   0.000     .0147333    .0239979
                            age2 |  -.0000893   .0000247    -3.61   0.000    -.0001378   -.0000408
                            race |   .0810358   .0129523     6.26   0.000     .0556497    .1064219
                    ------------------------------------------------------------------------------
                    asdocx_func_nested_reg():  3301  subscript invalid
                                     <istmt>:     -  function returned error
                    r(3301);
                    
                    end of do-file
                    
                    r(3301);
                    
                    .
                    Any suggestions?
                    Ho-Chuan (River) Huang
                    Stata 17.0, MP(4)

                    Comment


                    • #11
                      I have fixed the bug, kindly update
                      Code:
                       
                       asdocx_update, beta
                      Regards
                      --------------------------------------------------
                      Attaullah Shah, PhD.
                      Professor of Finance, Institute of Management Sciences Peshawar, Pakistan
                      FinTechProfessor.com
                      https://asdocx.com
                      Check out my asdoc program, which sends outputs to MS Word.
                      For more flexibility, consider using asdocx which can send Stata outputs to MS Word, Excel, LaTeX, or HTML.

                      Comment


                      • #12
                        Dear Attaullah, Thanks a lot.
                        Ho-Chuan (River) Huang
                        Stata 17.0, MP(4)

                        Comment

                        Working...
                        X