
Last chance! 50% off unlimited learning
Sale ends in
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))
Poisson response; number of counts
synthetic data set
number of observations in model, Default is 50000
optional: log of offset variable
predictor coefficient values. First argument is intercept. Use as xv = c(intercept , x1_coef, x2_coef, ...)
Joseph M. Hilbe, Arizona State University, and Jet Propulsion Laboratory, California Institute of Technology Andrew Robinson, Universty of Melbourne, Australia.
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.
Hilbe, J.M. (2011), Negative Binomial Regression, second edition, Cambridge University Press.
nb2_syn
# 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))
if (FALSE) {
# 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