0
$\begingroup$

Probably this question has no sense but I am really confused and I need help. I have a panel data model. I ran a fixed effect negative binomial regression for a variable which indicates the number of years a government stays in office. How may I compute the "amount" of the influence of an independent dummy variable over the dependent? and for a non-dummy? Why "Margins,dydx(_all)" in Stata returns the same coefficients of the Fixed Effect model?

$\endgroup$
  • 1
    $\begingroup$ Although asked in terms of Stata, this is really a statistical question. $\endgroup$ – gung - Reinstate Monica Feb 20 '18 at 4:27
1
$\begingroup$

In the panel NB model, the expected number of events is

$$E[y \vert x]=\exp\{\alpha +\beta x + \gamma_i\}.$$

By default, margins, dydx(.) gives you the effect on the index function (the part inside $\exp\{.\}$), so you just get back the reported coefficients since the index function is linear.

By altering the predict() option, you can get average marginal effects (AMEs) on the number of events, which is the average of the derivatives of the expression above with respect to $x$:

$$AME =\frac{\sum_i^N\exp\{\alpha +\beta \cdot x_{it} + \gamma_i\} \cdot \beta}{N}$$

However, Stata will evaluate each derivative as if the fixed effect $\gamma_i$ was zero for all $i$. This happens because the xtnbreg, fe model is estimated by a method known as conditional maximum likelihood. Here the FE for each individual are conditioned out of the likelihood function. This means that they are not available to be plugged in since these nuisance parameters are eliminated to make estimation easier/feasible. However, I believe they sum up to zero, so the AME can be interpreted as the AME as if everyone had the typical FE and their own covariates. I cannot find this explicitly stated in the documentation, so take that with a grain of salt.

Here's some Stata code showing this:

. webuse airacc, clear

. xtset airline
       panel variable:  airline (balanced)

. /* Index function coefficients*/
. xtnbreg i_cnt inprog, exposure(pmiles) fe nolog

Conditional FE negative binomial regression     Number of obs     =         80
Group variable: airline                         Number of groups  =         20

                                                Obs per group:
                                                              min =          4
                                                              avg =        4.0
                                                              max =          4

                                                Wald chi2(1)      =       2.11
Log likelihood  = -174.25143                    Prob > chi2       =     0.1463

------------------------------------------------------------------------------
       i_cnt |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
      inprog |  -.0984214   .0677414    -1.45   0.146    -.2311921    .0343492
       _cons |  -3.414208   1.006801    -3.39   0.001    -5.387501   -1.440915
  ln(pmiles) |          1  (exposure)
------------------------------------------------------------------------------

. margins, dydx(inprog)

Average marginal effects                        Number of obs     =         80
Model VCE    : OIM

Expression   : Linear prediction, predict()
dy/dx w.r.t. : inprog

------------------------------------------------------------------------------
             |            Delta-method
             |      dy/dx   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
      inprog |  -.0984214   .0677414    -1.45   0.146    -.2311921    .0343492
------------------------------------------------------------------------------

. margins, dydx(inprog) predict(xb) // same as above

Average marginal effects                        Number of obs     =         80
Model VCE    : OIM

Expression   : Linear prediction, predict(xb)
dy/dx w.r.t. : inprog

------------------------------------------------------------------------------
             |            Delta-method
             |      dy/dx   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
      inprog |  -.0984214   .0677414    -1.45   0.146    -.2311921    .0343492
------------------------------------------------------------------------------

. /* AME assuming fixed effects is zero */
. margins, dydx(inprog) predict(nu0)

Average marginal effects                        Number of obs     =         80
Model VCE    : OIM

Expression   : Predicted number of events (assuming u_i=0), predict(nu0)
dy/dx w.r.t. : inprog

------------------------------------------------------------------------------
             |            Delta-method
             |      dy/dx   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
      inprog |  -9.695908   11.62238    -0.83   0.404    -32.47535    13.08354
------------------------------------------------------------------------------

. gen double ME = exp(_b[_cons] + _b[inprog]*inprog + 1*ln(pmiles)) * _b[inprog]

. sum ME

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
          ME |         80   -9.695907    1.776251  -12.94475  -6.500259

I am using a logarithmic offset for miles flown to make events proportional to miles flown, and treating inprog as if it was continuous rather than binary (since that is more similar to your situation). The AME is 9.7 fewer injury incidents from participating in an experimental safety training program across all airlines given their miles flown history.

You can also still interpret the index function coefficient as a kind of semi-elasticity. Here a one unit change in inprog is associated with a $100 \cdot \beta=-9.84 \%$ drop in events. This does not require you to fix $\gamma_i=0$.

$\endgroup$
  • $\begingroup$ Does it make sense to use a negative binomial model to predict "the number of years a government stays in office"? $\endgroup$ – gung - Reinstate Monica Feb 20 '18 at 4:27
  • $\begingroup$ @gung I think it depends on the institutional details of the sample. Is there any statistical reason to assume it is inappropriate? $\endgroup$ – Dimitriy V. Masterov Feb 20 '18 at 4:36
  • $\begingroup$ My first thought on seeing a 'how long until...' question is that it should be a survival model. NB can be interpreted as the number of coin flips until a tails, but that doesn't seem like a great match for how many years until the government falls to me. I could be wrong here; this was a sincere question. $\endgroup$ – gung - Reinstate Monica Feb 20 '18 at 4:39
  • $\begingroup$ Thank you very much! But your answer leads me to a second question. Is there any distinction between the interpretation of a binary variable and a continuous one? $\endgroup$ – Alessio Feb 20 '18 at 9:38
  • $\begingroup$ @Alessio In non-linear models, the derivative corresponds to the change in $y$ for an infinitesimal change in $x$. For things like gender, a small change doesn't make much sense. For categorical variables that are prefixed with i., margins, dydx() will calculate marginal effects using finite difference in predicted events (relative to the base outcome), rather than derivatives. The index function coefficient will be the same, but the marginal effect will usually vary. It can often make an appreciable difference when the function is very nonlinear. $\endgroup$ – Dimitriy V. Masterov Feb 20 '18 at 17:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.