[R] help with zicounts

Van Wyk, Jaap jaapvw at uj.ac.za
Fri Mar 9 07:36:38 CET 2007


Dear UseRs:

I have simulated data from a zero-inflated Poisson model, and would like
to use a package like zicounts to test my code of fitting the model.
My question is: can I use zicounts directly with the following simulated
data?

Create a sample of n=1000 observations from a ZIP model with no intercept
and a single covariate x_{i} which is N(0,1). The logit part is
   logit(p_{i})=x_{i}*beta
with beta=1, and the Poisson part is
   log(µ_{i})=x_{i}*gamma
with gamma=1.

beta.true<-1.0
gamma.true<-1.0
n<-1000
x<-matrix(rnorm(n),n,1)
pi<-expit(x*beta.true)
mu<-exp(x*gamma.true)
y<-numeric(n) # blank vector
z<-(runif(n)<pi) # logical: T with prob p_i, F otherwise
y[z]<-rpois(sum(z),mu[z]) # draw y_i ~ Poisson(mu_i) where z_i = T
y[!z]<-0 # set y_i = 0 where z_i = F

Thanks for your time!
Jacob



Jacob L van Wyk
Department of Statistics
University of Johannesburg, APK
P O Box 524
Auckland Park 2006
South Africa
Tel: +27 11 489 3080
Fax: +27 11 489 2832



More information about the R-help mailing list