Learn R Programming

COUNT (version 1.3.2)

poisson_syn: Poisson : generic synthetic Poisson data and model

Description

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

Usage

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, ...)

Value

  • pyPoisson response; number of counts
  • sim.datasynthetic data set

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.

References

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

See Also

nb2_syn

Examples

Run this code
# 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))

# default (without offset)
sim.data <- poisson_syn()
dmypo <- glm( py ~ . , family=poisson, data = sim.data)
summary(dmypo)

Run the code above in your browser using DataLab