Announcement

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

  • e(b) with logistic regression output

    After running a logistic regression, my matrix e(b) contained values that were different from the coefficients. It took me a while to figure out these were the logarithms (i.e., the output that would be visualized if I ran a logit). Is this generally true? Is so, why does stata do this?

  • #2
    Yes, this is true. And, in general, when Stata estimates a model, it estimates regression coefficients. The -logistic- command is just a convenience command that runs -logit- and displays the results in the odds ratio metric instead. But its internal workings are those of -logit-. This convention holds throughout Stata. For example, if you run a Poisson regression to estimate incidence rate ratio, specifying the -irr- option, you get IRR's displayed in the Results window (and in your log file), but e(b) contains the Poisson regression coefficients.

    As for why Stata does this, you would have to ask the developers. But my guess is that it's because almost all post-estimation commands require the coefficients, not some transform of the coefficients that humans find more interesting, as ingredients.

    Comment


    • #3
      Yes, this is true and there is nothing wrong with that since that is exactly what logistic regression does. You can always take the exponent of the values in the e(b) to get the Odds Ratio.

      Comment


      • #4
        I would say -logistic- isn't giving you the coefficients, it is giving you the odds ratios. But note that the odds ratios are stored in r(table) if you want them:

        Code:
        . webuse nhanes2f, clear
        
        . logistic diabetes female
        
        Logistic regression                             Number of obs     =     10,335
                                                        LR chi2(1)        =       3.40
                                                        Prob > chi2       =     0.0654
        Log likelihood = -1997.3688                     Pseudo R2         =     0.0008
        
        ------------------------------------------------------------------------------
            diabetes | Odds Ratio   Std. Err.      z    P>|z|     [95% Conf. Interval]
        -------------+----------------------------------------------------------------
              female |   1.185349   .1096812     1.84   0.066     .9887447    1.421048
               _cons |   .0462489   .0032114   -44.27   0.000     .0403643    .0529915
        ------------------------------------------------------------------------------
        Note: _cons estimates baseline odds.
        
        . mat list e(b)
        
        e(b)[1,2]
              diabetes:   diabetes:
                female       _cons
        y1   .17003766  -3.0737169
        
        . mat list r(table)
        
        r(table)[9,2]
                  diabetes:   diabetes:
                    female       _cons
             b   1.1853495   .04624893
            se   .10968118   .00321136
             z   1.8376358  -44.266605
        pvalue    .0661161           0
            ll   .98874471   .04036429
            ul   1.4210477   .05299149
            df           .           .
          crit    1.959964    1.959964
         eform           1           1
        
        .
        -------------------------------------------
        Richard Williams, Notre Dame Dept of Sociology
        StataNow Version: 19.5 MP (2 processor)

        EMAIL: [email protected]
        WWW: https://www3.nd.edu/~rwilliam

        Comment


        • #5
          Mr. Williams,

          Do you know the code for saving the standard error of odds ratio for later use?

          Thank you in advance!

          Comment


          • #6
            The standard errors are reported directly below the odds ratios in the matrix r(table) that Richard showed in #4
            ---------------------------------
            Maarten L. Buis
            University of Konstanz
            Department of history and sociology
            box 40
            78457 Konstanz
            Germany
            http://www.maartenbuis.nl
            ---------------------------------

            Comment


            • #7
              r(table) displays the values. If I want to save the standard error to be used in other calculations, then I'll need to do the following:

              matrix t = r(table)
              matrix list t
              scalar stderror = t[2,1]

              Comment


              • #8
                This is a really helpful thread! I was stumped on this problem, and and it really helped. Just wanted to add an additional piece for any poor schmuck like me who was still stumped. I wasn't seeing ORs in my r(table), and then realized that I had a "contrast" statement after my logistic. Removing that made it all work
                ****************************
                Survey Methodologist
                California Health Interview Survey

                Comment

                Working...
                X