zelig-poisson

Poisson Regression for Event Count Dependent Variables

Use the Poisson regression model if the observations of your dependent variable represents the number of independent events that occur during a fixed period of time (see the negative binomial model, , for over-dispersed event counts.) For a Bayesian implementation of this model, see .

Syntax

With reference classes:

z5 <- zpoisson$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 = "poisson", weights = w, data = mydata)
x.out <- setx(z.out)
s.out <- sim(z.out, x = x.out)

Example

Load sample data:

data(sanction)

Estimate Poisson model:

z.out <- zelig(num ~ target + coop, model = "poisson", 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:
##   R Core Team. 2007.
##   poisson: Poisson 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
## -7.213  -1.183  -0.208  -0.186  17.651
##
## Coefficients:
##             Estimate Std. Error z value Pr(>|z|)
## (Intercept)  -0.9677     0.1755   -5.52  3.5e-08
## target       -0.0210     0.0582   -0.36     0.72
## coop          1.2108     0.0466   25.97  < 2e-16
##
## (Dispersion parameter for poisson family taken to be 1)
##
##     Null deviance: 1583.77  on 77  degrees of freedom
## Residual deviance:  720.84  on 75  degrees of freedom
## AIC: 944.3
##
## Number of Fisher Scoring iterations: 6
##
## Next step: Use 'setx' method

Set values for the explanatory variables to their default mean values, while changing the coop variable across its range:

x.low <- setx(z.out, coop=1)
x.high <- setx1(z.out, coop=4)

Simulate fitted values:

s.out <- sim(z.out, x = x.low, x1=x.high)
summary(s.out)
##
##  sim x :
##  -----
## ev
##      mean    sd  50%  2.5% 97.5%
## [1,] 1.22 0.123 1.21 0.998  1.47
## pv
##      mean   sd 50% 2.5% 97.5%
## [1,] 1.24 1.09   1    0     4
##
##  sim x1 :
##  -----
## ev
##      mean   sd  50% 2.5% 97.5%
## [1,] 46.2 2.88 46.1 40.5    52
## pv
##      mean   sd 50% 2.5% 97.5%
## [1,] 45.7 7.15  46   33    60
## fd
##      mean   sd  50% 2.5% 97.5%
## [1,] 44.9 2.92 44.9 39.3    51
plot(s.out)

Graphs of Quantities of Interest for Zelig-poisson

Model

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

  • The Poisson distribution has stochastic component

    where is the mean and variance parameter.

  • The systematic component is

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

Quantities of Interest

  • The expected value (qi$ev) is the mean of simulations from the stochastic component,

    given draws of \beta from its sampling distribution.

  • The predicted value (qi$pr) is a random draw from the poisson distribution defined by mean .

  • The first difference in the expected values (qi$fd) is given by:

  • 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 poisson model is part of the stats package by the R Core Team. Advanced users may wish to refer to help(glm) and help(family).

R Core Team (2017). R: A Language and Environment for Statistical Computing. R Foundation for Statistical Computing, Vienna, Austria. <URL: https://www.R-project.org/>.