Announcement

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

  • When to divide in subpopulations, using the margins command (AME) in a logit model?

    My goal is to compare the AMEs between two subpopulations of my sample in a logit model. However, there are two different moments in my analysis I can think of on where I can divide my sample into those two subpopulations, leading to very different results.
    In the example below y would be my binary dependent variable; a and b are covariates and subpop is a dummy, dividing my sample into those two subgroups.

    Possibility 1:
    forval i=0/1 {
    logit y a b if subpop==`i'
    margins, dydx(a b)
    }
    Possibility 2:
    forval i=0/1 {
    logit y a b i.subpop
    margins if rich==`i', dydx(a b)
    }
    I know for the latter code, the over() and the subpop() command can be used as well, which does not change the results with my data. What does change the magnitude of the effects of a and b on y tremendously is whether I divide my population before the logit command is executed or after the logit command is executed (i.e. before the margins command is executed). So my question is, which option is the “correct” one or rather how do the two options differ in the interpretation of results?
    Thanks a lot in advance!

  • #2
    Hannah, if you'd like to compare AMEs between subsamples, I think "Possibility 1" is correct. "Possibility 2" uses both subsamples to estimate only one set of coefficients and the difference in AMEs between subsamples only reflects the difference in regressors' distributions between subsamples. There is a "Possibility 3" which is equivalent to "Possibility 1", as below -- The key is to allow coefficients to differ between subsamples.

    Code:
    .         sysuse auto, clear
    (1978 Automobile Data)
    
    .         gen subpop = runiformint(0,1)  
    
    .
    . * Possibility 1
    .         quietly logit foreign price mpg if subpop == 0
    
    .         margins, dydx(price mpg)
    
    Average marginal effects                        Number of obs     =         36
    Model VCE    : OIM
    
    Expression   : Pr(foreign), predict()
    dy/dx w.r.t. : price mpg
    
    ------------------------------------------------------------------------------
                 |            Delta-method
                 |      dy/dx   Std. Err.      z    P>|z|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
           price |   .0000267   .0000203     1.31   0.189    -.0000131    .0000665
             mpg |   .0388941   .0078245     4.97   0.000     .0235584    .0542299
    ------------------------------------------------------------------------------
    
    .         quietly logit foreign price mpg if subpop == 1
    
    .         margins, dydx(price mpg)
    
    Average marginal effects                        Number of obs     =         38
    Model VCE    : OIM
    
    Expression   : Pr(foreign), predict()
    dy/dx w.r.t. : price mpg
    
    ------------------------------------------------------------------------------
                 |            Delta-method
                 |      dy/dx   Std. Err.      z    P>|z|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
           price |   .0000881   .0000244     3.62   0.000     .0000404    .0001359
             mpg |   .0395933   .0123098     3.22   0.001     .0154666    .0637201
    ------------------------------------------------------------------------------
    
    .        
    . * Possibility 2
    .         quietly logit foreign price mpg subpop
    
    .         margins if subpop == 0, dydx(price mpg)
    
    Average marginal effects                        Number of obs     =         36
    Model VCE    : OIM
    
    Expression   : Pr(foreign), predict()
    dy/dx w.r.t. : price mpg
    
    ------------------------------------------------------------------------------
                 |            Delta-method
                 |      dy/dx   Std. Err.      z    P>|z|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
           price |   .0000457   .0000171     2.67   0.008     .0000122    .0000793
             mpg |   .0386779   .0070581     5.48   0.000     .0248443    .0525116
    ------------------------------------------------------------------------------
    
    .         margins if subpop == 1, dydx(price mpg)
    
    Average marginal effects                        Number of obs     =         38
    Model VCE    : OIM
    
    Expression   : Pr(foreign), predict()
    dy/dx w.r.t. : price mpg
    
    ------------------------------------------------------------------------------
                 |            Delta-method
                 |      dy/dx   Std. Err.      z    P>|z|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
           price |   .0000465   .0000194     2.40   0.016     8.59e-06    .0000845
             mpg |   .0393567   .0098298     4.00   0.000     .0200906    .0586229
    ------------------------------------------------------------------------------
    
    .        
    . * Possibility 3
    .         quietly logit foreign price mpg subpop c.price#c.subpop c.mpg#c.subpop
    
    .         margins if subpop == 0, dydx(price mpg)
    
    Average marginal effects                        Number of obs     =         36
    Model VCE    : OIM
    
    Expression   : Pr(foreign), predict()
    dy/dx w.r.t. : price mpg
    
    ------------------------------------------------------------------------------
                 |            Delta-method
                 |      dy/dx   Std. Err.      z    P>|z|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
           price |   .0000267   .0000203     1.31   0.189    -.0000131    .0000665
             mpg |   .0388941   .0078245     4.97   0.000     .0235584    .0542299
    ------------------------------------------------------------------------------
    
    .         margins if subpop == 1, dydx(price mpg)
    
    Average marginal effects                        Number of obs     =         38
    Model VCE    : OIM
    
    Expression   : Pr(foreign), predict()
    dy/dx w.r.t. : price mpg
    
    ------------------------------------------------------------------------------
                 |            Delta-method
                 |      dy/dx   Std. Err.      z    P>|z|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
           price |   .0000881   .0000244     3.62   0.000     .0000404    .0001359
             mpg |   .0395933   .0123098     3.22   0.001     .0154666    .0637201
    ------------------------------------------------------------------------------
    Last edited by Fei Wang; 13 Nov 2021, 06:32.

    Comment


    • #3
      Hi Fei, ok I think I got it, you helped me a lot with your detailed answer, thank you so much!

      Comment

      Working...
      X