Announcement

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

  • Negative predicted values after xtnbreg on nested count data

    I am analyzing how many comments a social media picture of a women gets based on how good looking the woman in the picture is and the extent to which her image has been altered (e.g., heavy make up, photoshop, cosmetic surgery). The dependent variable ( photo_comments) is count data and the predictor variables are continuous and have been standardized to convert them into a common scale ( z_altered and z_fem_beauty). Because the data are nested within the poster's account and overdispersed, I use xtnbreg to conduct the analysis and used xtpoisson as a sanity check.I use the number of followers to the account as the exposure variable.

    Code:
    . sum photo_comments, detail
    
                           photo_comments
    -------------------------------------------------------------
          Percentiles      Smallest
     1%            0              0
     5%            0              0
    10%            0              0       Obs               5,866
    25%            0              0       Sum of Wgt.       5,866
    
    50%         18.5                      Mean           5435.123
                            Largest       Std. Dev.       27906.4
    75%         1055         430655
    90%         8770         481069       Variance       7.79e+08
    95%        25388         803284       Skewness       19.18279
    99%       122844        1139151       Kurtosis       616.2378

    When I run the margins command after xtnbreg, I get negative expected values for the count, which doesn't make sense. Do you have any explanations for why the predicted values are negative?

    Code:
     xtnbreg photo_comments  c.z_altered##c.z_fem_beauty,  exp(followers1) fe
    
    Conditional FE negative binomial regression     Number of obs     =        481
    Group variable: account_id                      Number of groups  =         65
    
                                                    Obs per group:
                                                                  min =          2
                                                                  avg =        7.4
                                                                  max =         34
    
                                                    Wald chi2(3)      =     167.11
    Log likelihood  = -3886.7958                    Prob > chi2       =     0.0000
    
    --------------------------------------------------------------------------------------------
                photo_comments |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
    ---------------------------+----------------------------------------------------------------
                     z_altered |  -.7177536   .0586089   -12.25   0.000    -.8326249   -.6028823
                  z_fem_beauty |   .2723421   .0607985     4.48   0.000     .1531793    .3915048
                               |
    c.z_altered#c.z_fem_beauty |   .3414562    .052084     6.56   0.000     .2393735     .443539
                               |
                         _cons |  -17.93335   .0660347  -271.57   0.000    -18.06277   -17.80392
                ln(followers1) |          1  (exposure)
    --------------------------------------------------------------------------------------------
    
    margins ,at(z_fem_beauty= (0 1) z_altered=(0 1))
    
    
    ------------------------------------------------------------------------------
                 |            Delta-method
                 |     Margin   Std. Err.      z    P>|z|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
             _at |
              1  |  -4.021224   .0660347   -60.90   0.000     -4.15065   -3.891798
              2  |  -3.748882   .0918066   -40.83   0.000     -3.92882   -3.568944
              3  |  -4.738978    .093584   -50.64   0.000    -4.922399   -4.555556
              4  |  -4.125179   .0923395   -44.67   0.000    -4.306161   -3.944197
    ------------------------------------------------------------------------------
    When I conduct the same analysis and margins command using xtpoisson, all the predicted values are positive, as they should be.

    Code:
    . xtpoisson photo_comments  c.z_altered##c.z_fem_beauty,  exp(followers1)  fe
    
    Conditional fixed-effects Poisson regression    Number of obs     =        481
    Group variable: account_id                      Number of groups  =         65
    
                                                    Obs per group:
                                                                  min =          2
                                                                  avg =        7.4
                                                                  max =         34
    
                                                    Wald chi2(3)      =   72928.93
    Log likelihood  = -1280726.3                    Prob > chi2       =     0.0000
    
    --------------------------------------------------------------------------------------------
                photo_comments |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
    ---------------------------+----------------------------------------------------------------
                     z_altered |  -.1015437   .0009827  -103.33   0.000    -.1034697   -.0996177
                  z_fem_beauty |   .0826125    .001004    82.29   0.000     .0806448    .0845803
                               |
    c.z_altered#c.z_fem_beauty |    .119922   .0006979   171.84   0.000     .1185542    .1212898
                ln(followers1) |          1  (exposure)
    --------------------------------------------------------------------------------------------
    
    
    
    . margins ,at(z_fem_beauty= (0 1) z_altered=(0 1))
    
    
    ------------------------------------------------------------------------------
                 |            Delta-method
                 |     Margin   Std. Err.      z    P>|z|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
             _at |
              1  |   13.91212          .        .       .            .           .
              2  |   13.99474    .001004  1.4e+04   0.000     13.99277     13.9967
              3  |   13.81058   .0009827  1.4e+04   0.000     13.80865    13.81251
              4  |   14.01311   .0010905  1.3e+04   0.000     14.01098    14.01525
    ------------------------------------------------------------------------------

  • #2
    In both cases you have chosen the default statistic for your margins command. But looking at the description of the margins command in the output of help xtnbreg postestimation and that in the output of help xtpoisson postestimation suggests to me that you may want to choose some other statistic in the margins for your xtnbreg and perhaps also for your xtpoisson.

    Comment


    • #3
      Dear robertekraut,

      I am afraid there are a number of issues here, one of them is much more serious than the others.

      As I have discussed here, margins should not be available after either of these commands because it always produces nonsensical results. The explanation for that is simple: Any interesting quantity that we may want to compute will depend on the value of the fixed effects, which are not estimated by these commands. Therefore, margins computes something that most of the times is meaningless. I had been promised that margins would be disabled after this kind of commands but that did not happen. Maybe Gustavo Sanchez (StataCorp), who contacted me about this about a year ago, can give us an update.

      Additionally, xtnbreg with the fe option is not a proper fixed effects model and should generally be avoided; please see the discussion here. Finally, we should always use robust standard errors with any of these commands.

      Best wishes,

      Joao

      Comment


      • #4
        Joao, Thank you very much for the pointers and the advice. I now understand that xtnbreg with the fe option isn't appropriate and that margins gives meaningless estimates for both xtnbreg and xtpoisson. However, will xtpoisson with the re and vce(robust) options give valid coefficients and IRRs?

        Thanks again,
        bob kraut

        Comment


        • #5
          Dear robertekraut,

          After xtpoisson with re, margins will give something more meaningful but still not particularly useful. If I am not mistaken, it provides estimates of some quantity evaluated at the mean of the random effects but, because of the Jensen's inequality, that is not generally the mean of the quantity of interest. In any case, I would not use xtpoisson with re because it is sensitive to the assumption made about the distribution of the random effects.

          In Poisson regression (unlike, e.g., in the logit) the coefficients have a clear and interesting interpretation as (semi-) elasticities, so you do not really need to use margins if you use xtpoisson with fe. Alternatively, if you restrict your sample to the groups with enough observations (say, 10 or 12), you can just estimate a Poisson regression with a dummy for each group and then use margins.

          Best wishes,

          Joao

          Comment

          Working...
          X