poisson_syn function

Poisson : generic synthetic Poisson data and model

Poisson : generic synthetic Poisson data and model

poisson_syn is a generic function for developing synthetic Poisson data and a model given user defined specifications.

poisson_syn(nobs = 50000, off = 0, xv = c(1, -.5, 1))

Arguments

  • nobs: number of observations in model, Default is 50000
  • off: optional: log of offset variable
  • xv: predictor coefficient values. First argument is intercept. Use as xv = c(intercept , x1_coef, x2_coef, ...)

Details

Create a synthetic Poisson regression model using the appropriate arguments. Offset optional. Model data with predictors indicated as a group with a period (.). See examples.

Returns

  • py: Poisson response; number of counts

  • sim.data: synthetic data set

References

Hilbe, J.M. (2011), Negative Binomial Regression, second edition, Cambridge University Press.

Author(s)

Joseph M. Hilbe, Arizona State University, and Jet Propulsion Laboratory, California Institute of Technology Andrew Robinson, Universty of Melbourne, Australia.

See Also

nb2_syn

Examples

# standard Poisson model with two predictors and intercept sim.data <- poisson_syn(nobs = 500, xv = c(2, .75, -1.25)) mypo <- glm(py ~ . , family=poisson, data = sim.data) summary(mypo) confint(mypo) # Poisson with offset and three predictors oset <- rep(1:5, each=100, times=1)*100 loff <- log(oset) sim.data <- poisson_syn(nobs = 500, off = loff, xv = c(1.2, -.75, .25, -1.3)) mypof <- glm(py ~ . + loff, family=poisson, data = sim.data) summary(mypof) confint(mypof) # Poisson without offset, exponentiated coefficients, CI's sim.data <- poisson_syn(nobs = 500, xv = c(2, .75, -1.25)) mypo <- glm(py ~ . , family=poisson, data = sim.data) exp(coef(mypo)) exp(confint(mypo)) ## Not run: # default (without offset) sim.data <- poisson_syn() dmypo <- glm( py ~ . , family=poisson, data = sim.data) summary(dmypo) ## End(Not run)
  • Maintainer: Andrew Robinson
  • License: GPL-2
  • Last published: 2016-10-19

Useful links