Announcement

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

  • What's exactly the grand mean used by "margins gw." command?

    Hello,
    This is my first post here in the forum, but I have frequently visited this forum. Very useful information here, thank you!
    I have a very specific question: What's exactly the grand mean used by "margins gw." command?
    I find that, after logit regression (see and example below), the differences between levels of a factor variable (e.g. "race") are the same with "margins" and "margins gw.":
    Code:
    webuse nhanes2f, clear
    logit diabetes i.female weight height i.race
    margins race, grand
    margins gw.race
    However, the considered grand mean is not the same. Why "margins gw." doesn't use the grand mean given by "margins"?

  • #2
    Welcome to the Stata Forum/Statalist,

    "gw" is for difference from the weighted grand mean whereas "g" is for difference from the balanced grand mean.
    Best regards,

    Marcos

    Comment


    • #3
      Thank you so much for your answer, Marcos Almeida. My question is not about the difference between "gw" and "g" grand means, but about the difference between "gw" grand mean and "margins" grand mean. Is the "margins" grand mean a weighted one?

      Let's go back to my example:
      Code:
      webuse nhanes2f, clear
      logit diabetes i.female weight height i.race
      margins race, grand
      The last command returns a grand mean = .0482825. Running "margins, dydx(race)" returns the same results as manually calculating the differences between the predictive "margins" for each group minus that grand mean. However,
      Code:
      margins gw.race
      does not return the same results in its contrasts of predictive margins
      and the implicit* (weighted) grand mean would be .0480315 [*assuming that predictive margins and marginal effects are always the same].

      So, again, why are those margin coefficients and grand means different?

      Comment


      • #4
        In the example below, we can get these results:

        Code:
        . sysuse auto
        (1978 Automobile Data)
        
        . gen highmpg = mpg > 21
        
        . quiet: logit foreign price weight i.highmpg
        
        . margins highmpg, grand
        
        Predictive margins                              Number of obs     =         74
        Model VCE    : OIM
        
        Expression   : Pr(foreign), predict()
        
        ------------------------------------------------------------------------------
                     |            Delta-method
                     |     Margin   Std. Err.      z    P>|z|     [95% Conf. Interval]
        -------------+----------------------------------------------------------------
             highmpg |
                  0  |   .3963082   .0367545    10.78   0.000     .3242708    .4683456
                  1  |   .2327371   .0377345     6.17   0.000      .158779    .3066953
                     |
               _cons |   .2972973   .0300242     9.90   0.000      .238451    .3561436
        ------------------------------------------------------------------------------
        
        . di 0.3963082 - 0.2327371
        .1635711
        
        . margins gw.highmpg
        
        Contrasts of predictive margins
        Model VCE    : OIM
        
        Expression   : Pr(foreign), predict()
        
        ------------------------------------------------
                     |         df        chi2     P>chi2
        -------------+----------------------------------
             highmpg |
        (0 vs mean)  |          1        8.32     0.0039
        (1 vs mean)  |          1        8.32     0.0039
              Joint  |          1        8.32     0.0039
        ------------------------------------------------
        
        --------------------------------------------------------------
                     |            Delta-method
                     |   Contrast   Std. Err.     [95% Conf. Interval]
        -------------+------------------------------------------------
             highmpg |
        (0 vs mean)  |    .068523   .0237621      .0219501    .1150959
        (1 vs mean)  |   -.095048   .0329603     -.1596491    -.030447
        --------------------------------------------------------------
        
        . di 0.068523 - (-0.095048)
        .163571
        Last edited by Marcos Almeida; 13 Jun 2018, 05:00.
        Best regards,

        Marcos

        Comment


        • #5
          Thank you again, Marcos Almeida.
          What you calculated in your example are the marginal effects between categories or levels and, yes, they are the same in both "margins, grand" and "margins gw.". I am not talking about those effects but about the marginal effects with respect to the grand means in each case, meaning that the issue is focused on the grand means. So, in your example, my questions would be:
          -> Why "di .3963082 - .2972973" [i.e. predictive margin of '0' minus 'population averaged' grand mean] returns a different result (= .0990109) than the contrast "0 vs mean" [i.e. marginal effect of '0' minus 'weighted observed' grand mean] does (= .068523)?
          -> If the grand means are different, why and how can each one be defined?

          Comment

          Working...
          X