zelig-negbin

Negative Binomial Regression for Event Count Dependent Variables

Use the negative binomial regression if you have a count of events for each observation of your dependent variable. The negative binomial model is frequently used to estimate over-dispersed event count models.

Syntax

With reference classes:

z5 <- znegbin$new()
z5$zelig(Y ~ X1 + X ~ X, weights = w, data = mydata)
z5$setx()
z5$sim()

With the Zelig 4 compatibility wrappers:

z.out <- zelig(Y ~ X1 + X2, model = "negbin", weights = w, data = mydata)
x.out <- setx(z.out)
s.out <- sim(z.out, x = x.out)

Example

Load sample data:

data(sanction)

Estimate the model:

z.out <- zelig(num ~ target + coop, model = "negbin", data = sanction)
## Warning in readLines(zeligmixedmodels): incomplete final line found on
## '/usr/lib64/R/library/ZeligMultilevel/JSON/zelig5mixedmodels.json'
## How to cite this model in Zelig:
##   William N. Venables, and Brian D. Ripley. 2008.
##   negbin: Negative Binomial Regression for Event Count Dependent Variables
##   in Christine Choirat, Christopher Gandrud, James Honaker, Kosuke Imai, Gary King, and Olivia Lau,
##   "Zelig: Everyone's Statistical Software," http://zeligproject.org/
summary(z.out)
## Model:
##
## Call:
## z5$zelig(formula = num ~ target + coop, data = sanction)
##
## Deviance Residuals:
##    Min      1Q  Median      3Q     Max
## -2.030  -0.512  -0.142  -0.019   3.999
##
## Coefficients:
##             Estimate Std. Error z value Pr(>|z|)
## (Intercept)   -1.564      0.394   -3.97  7.3e-05
## target         0.151      0.144    1.05     0.29
## coop           1.286      0.110   11.70  < 2e-16
##
## (Dispersion parameter for Negative Binomial(1.84) family taken to be 1)
##
##     Null deviance: 237.094  on 77  degrees of freedom
## Residual deviance:  56.545  on 75  degrees of freedom
## AIC: 360.2
##
## Number of Fisher Scoring iterations: 1
##
##
##               Theta:  1.842
##           Std. Err.:  0.353
##
##  2 x log-likelihood:  -352.188
## Next step: Use 'setx' method

Set values for the explanatory variables to their default mean values:

x.out <- setx(z.out)

Simulate fitted values:

s.out <- sim(z.out, x = x.out)
summary(s.out)
##
##  sim x :
##  -----
## ev
##      mean    sd  50% 2.5% 97.5%
## [1,] 2.96 0.342 2.95 2.35  3.69
## pv
##      mean   sd 50% 2.5% 97.5%
## [1,] 3.16 2.87   3    0    10
plot(s.out)

Graphs of Quantities of Interest for Zelig-negbin

Model

Let be the number of independent events that occur during a fixed time period. This variable can take any non-negative integer value.

  • The negative binomial distribution is derived by letting the mean of the Poisson distribution vary according to a fixed parameter given by the Gamma distribution. The stochastic component is given by

    The marginal distribution of is then the negative binomial with mean and variance :

    where is the systematic parameter of the Gamma distribution modeling .

  • The systematic component is given by

    where is the vector of explanatory variables and \beta is the vector of coefficients.

Quantities of Interest

  • The expected values (qi$ev) are simulations of the mean of the stochastic component. Thus,

    given simulations of \beta.

  • The predicted value (qi$pr) drawn from the distribution defined by the set of parameters .

  • The first difference (qi$fd) is

  • In conditional prediction models, the average expected treatment effect (att.ev) for the treatment group is

    where is a binary explanatory variable defining the treatment () and control () groups. Variation in the simulations are due to uncertainty in simulating , the counterfactual expected value of for observations in the treatment group, under the assumption that everything stays the same except that the treatment indicator is switched to .

  • In conditional prediction models, the average predicted treatment effect (att.pr) for the treatment group is

    where is a binary explanatory variable defining the treatment () and control () groups. Variation in the simulations are due to uncertainty in simulating , the counterfactual predicted value of for observations in the treatment group, under the assumption that everything stays the same except that the treatment indicator is switched to .

Output Values

The Zelig object stores fields containing everything needed to rerun the Zelig output, and all the results and simulations as they are generated. In addition to the summary commands demonstrated above, some simply utility functions (known as getters) provide easy access to the raw fields most commonly of use for further investigation.

In the example above z.out$getcoef() returns the estimated coefficients, z.out$getvcov() returns the estimated covariance matrix, and z.out$getpredict() provides predicted values for all observations in the dataset from the analysis.

See also

The negative binomial model is part of the MASS package by William N. Venable and Brian D. Ripley . Advanced users may wish to refer to help(glm.nb).

Venables WN and Ripley BD (2002). Modern Applied Statistics with S, Fourth edition. Springer, New York. ISBN 0-387-95457-0, <URL: http://www.stats.ox.ac.uk/pub/MASS4>.