Announcement

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

  • Different marginal effect for dummy variable after logit, depending on using i-prefix or not

    Hello,

    I'm wondering why margins (after logit) produces different results for a dummy variable (0-1) depending on whether the i-prefix is used or not. Estimates of coefficients of smoke are (logically) identical, but the marginal effect and standard error of smoke differ (0.1352669 vs.0.140626). See code and result below.

    Thank you,
    Mike


    Code:
    . webuse lbw
    (Hosmer & Lemeshow data)
    
    . logit low age lwt smoke
    
    Iteration 0:   log likelihood =   -117.336  
    Iteration 1:   log likelihood = -111.55075  
    Iteration 2:   log likelihood = -111.44794  
    Iteration 3:   log likelihood = -111.44776  
    Iteration 4:   log likelihood = -111.44776  
    
    Logistic regression                             Number of obs     =        189
                                                    LR chi2(3)        =      11.78
                                                    Prob > chi2       =     0.0082
    Log likelihood = -111.44776                     Pseudo R2         =     0.0502
    
    ------------------------------------------------------------------------------
             low |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
             age |    -.03902   .0327243    -1.19   0.233    -.1031585    .0251184
             lwt |  -.0121153   .0061336    -1.98   0.048    -.0241368   -.0000938
           smoke |   .6706699   .3258659     2.06   0.040     .0319845    1.309355
           _cons |    1.36601   1.014251     1.35   0.178    -.6218848    3.353905
    ------------------------------------------------------------------------------
    
    . margins, dydx(*)
    
    Average marginal effects                        Number of obs     =        189
    Model VCE    : OIM
    
    Expression   : Pr(low), predict()
    dy/dx w.r.t. : age lwt smoke
    
    ------------------------------------------------------------------------------
                 |            Delta-method
                 |      dy/dx   Std. Err.      z    P>|z|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
             age |  -.0078699   .0065191    -1.21   0.227    -.0206472    .0049073
             lwt |  -.0024435   .0011968    -2.04   0.041    -.0047892   -.0000979
           smoke |   .1352669   .0630567     2.15   0.032     .0116781    .2588556
    ------------------------------------------------------------------------------
    
    . logit low age lwt i.smoke
    
    Iteration 0:   log likelihood =   -117.336  
    Iteration 1:   log likelihood = -111.55075  
    Iteration 2:   log likelihood = -111.44794  
    Iteration 3:   log likelihood = -111.44776  
    Iteration 4:   log likelihood = -111.44776  
    
    Logistic regression                             Number of obs     =        189
                                                    LR chi2(3)        =      11.78
                                                    Prob > chi2       =     0.0082
    Log likelihood = -111.44776                     Pseudo R2         =     0.0502
    
    ------------------------------------------------------------------------------
             low |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
             age |    -.03902   .0327243    -1.19   0.233    -.1031585    .0251184
             lwt |  -.0121153   .0061336    -1.98   0.048    -.0241368   -.0000938
                 |
           smoke |
         smoker  |   .6706699   .3258659     2.06   0.040     .0319845    1.309355
           _cons |    1.36601   1.014251     1.35   0.178    -.6218848    3.353905
    ------------------------------------------------------------------------------
    
    . margins, dydx(*)
    
    Average marginal effects                        Number of obs     =        189
    Model VCE    : OIM
    
    Expression   : Pr(low), predict()
    dy/dx w.r.t. : age lwt 1.smoke
    
    ------------------------------------------------------------------------------
                 |            Delta-method
                 |      dy/dx   Std. Err.      z    P>|z|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
             age |  -.0078699   .0065191    -1.21   0.227    -.0206472    .0049073
             lwt |  -.0024435   .0011968    -2.04   0.041    -.0047892   -.0000979
                 |
           smoke |
         smoker  |    .140626   .0688897     2.04   0.041     .0056047    .2756473
    ------------------------------------------------------------------------------
    Note: dy/dx for factor levels is the discrete change from the base level.

  • #2
    Note the footnote at the bottom of the second (correct) set of margins.

    Note: dy/dx for factor levels is the discrete change from the base level.
    That is, if I have this correctly, margins recognizes that an arbitrarily small incremental change in age can make a corresponding small incremental change in the prediction, but a categorical variable can only take the values 0 and 1, so the the dy/dx reported is that for a change from 0 to 1.

    If you are not already familiar with these papers, you may find the explanation you need, and more, in the nice overview of margins prepared by Richard Williams, a frequent contributor here, at https://www3.nd.edu/~rwilliam/xsoc73994/Margins01.pdf with a more detailed paper in the Stata Journal at http://www.stata-journal.com/article...article=st0260. I'll also note that Margins01.pdf is followed by Margins02.pdf ... Margins05.pdf covering more specialized topics.

    And all five of these PDFs, and plenty more of use to someone learning about the analysis of categorical data, are linked to from https://www3.nd.edu/~rwilliam/xsoc73994/index.html - the material mentioned above is found in the section headed Interpreting results: Adjusted Predictions and Marginal effects.

    Comment


    • #3
      Thank you for your elaborate answer!

      Comment

      Working...
      X