Announcement

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

  • margins, eydx after logit

    Hi,

    I am working with a logit model. I am interested in the percentage change in the probability of a positive outcome when the treatment variable is binary. Consider, for instance, the impact of being in a "Grade 2" job on the probability of being a smoker. "gradd2" is a dummy variable. Here is my model:

    Code:
    use http://www.stata-press.com/data/r15/smoking.dta, clear 
    generate smoker = (cigs > 0) if !missing(cigs)
    logit smoker gradd2, nolog
    To compute the relative change in the probability of smoker, I type:

    Code:
    margins, eydx(gradd2)
    On average, individuals in gradd2 jobs are 33.4 percent more likely to be smokers.


    Question 1:

    Theoretically, this quantity should be arrived at by estimating the relative change in predicted probabilities: DeltaP/P = [L(a*1 - cons) - L(a*0 - cons)] / L(a*smoker - cons), where a is the coefficient on smoker, cons is the constant term, and L denotes the logisitc function. However, this does not seem to be the case:

    Code:
    margins, expression((1/(1+exp(-1*_b[gradd2]-_b[_cons])) - 1/(1+exp(-0*_b[gradd2]-_b[_cons])))*(1+exp(-gradd2*_b[gradd2]-_b[_cons])))
    Now, it appears that individuals in gradd2 jobs are 34.4 percent more likely to be smokers.

    The question is: what quantity exactly does "eydx" estimate after "logit"?


    Question 2:

    I now re-run the model, but I treat my gradd2 dummy explicitly as a factor variable:

    Code:
    logit smoker i.gradd2, nolog
    Now, the "margins" command returns a different value (30.7 percent more likely):

    Code:
    margins, eydx(gradd2)
    Why is this the case?


    Thanks a lot!

  • #2
    Still trying to figure this out.

    Any help or ideas would be most welcome!

    Luca

    Comment


    • #3
      Dear Statalist members,

      I have figured out the answer to my Question 2 above. When the i. prefix is not specified, Stata treats gradd2 as a continuous variable, and margins computes the derivative of the response, rather than the discrete first-difference from the base level

      I am still grappling with Question 1, though. "margins, eydx" should use the following expression for the response: [L(a*1 - cons) - L(a*0 - cons)] / L(a*smoker - cons). But it doesn't seem to. Does anyone know why?

      Here is the code:

      Code:
      use http://www.stata-press.com/data/r15/smoking.dta, clear
      Code:
      generate smoker = (cigs > 0) if !missing(cigs)
      logit smoker i.gradd2, nolog 
      margins, eydx(gradd2)
      margins, expression((1/(1+exp(-1*_b[1.gradd2]-_b[_cons])) - 1/(1+exp(-0*_b[1.gradd2]-_b[_cons])))*(1+exp(-1.gradd2*_b[1.gradd2]-_b[_cons])))
      Luca
      Last edited by Luca Uberti; 24 Oct 2019, 10:33.

      Comment

      Working...
      X