Solved – fixed effect and marginal effect in negative binomial

fixed-effects-modelmarginal-effectnegative-binomial-distribution

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?

Best Answer

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$.