Announcement

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

  • Margins at the median and all the other variables at zero level

    Hello people,

    I have run my LOGIT regression and now I want to obtain the marginal effect at the median for each single variable, while all the others shall be equal to zero. The following code in yellow and output do it that , but keep the other variables at their median level. How can I play around the code so to obtain what the desired outcome initially described?

    Many Thanks!
    Best
    Linda

    --------------------------------------------------------------------------------
    Click image for larger version

Name:	pp.PNG
Views:	1
Size:	32.2 KB
ID:	1603684

  • #2
    You can explicitly specify a value at which to set a particular variable. However, in your case, some values are not even possible. For example, I am certain that there is no year=0 if your median year is 2019, and I doubt that you have newborns sampled in your study.

    Code:
    webuse lbw, clear
    logit low age smoke ptl ht ui
    qui sum age, d
    local medage= r(p50)
    margins, dydx(*) at(age= `medage' smoke==0 ptl==0 ht==0 ui==0)
    Res.:

    Code:
    . margins, dydx(*) at(age= `medage' smoke==0 ptl==0 ht==0 ui==0)
    
    Conditional marginal effects                    Number of obs     =        189
    Model VCE    : OIM
    
    Expression   : Pr(low), predict()
    dy/dx w.r.t. : age smoke ptl ht ui
    at           : age             =          23
                   smoke           =           0
                   ptl             =           0
                   ht              =           0
                   ui              =           0
    
    ------------------------------------------------------------------------------
                 |            Delta-method
                 |      dy/dx   Std. Err.      z    P>|z|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
             age |  -.0085216   .0054285    -1.57   0.116    -.0191613    .0021181
           smoke |   .0876545    .047171     1.86   0.063    -.0047991     .180108
             ptl |   .1069912   .0537701     1.99   0.047     .0016037    .2123787
              ht |   .2217971   .0953514     2.33   0.020     .0349118    .4086824
              ui |   .1286365   .0678114     1.90   0.058    -.0042715    .2615444
    ------------------------------------------------------------------------------

    Comment


    • #3
      Hi Andrew,

      yeah what you say actually makes sense!

      Thank you very much for the illustrative example.

      Best,
      Linda

      Comment

      Working...
      X