# Generate some artificial data
phi = 0.35; lambda = 2
y = rzipois(n <- 1000, lambda, phi)
table(y)
# Two equivalent ways of fitting the same model
fit1 = vglm(y ~ 1, yip88(n=length(y)), subset=y>0, trace=TRUE, crit="c")
fit2 = vglm(y ~ 1, yip88, trace=TRUE, crit="c")
(true.mean = (1-phi) * lambda)
mean(y)
head(fitted(fit1))
fit1@misc$phi # The estimate of phi
# Compare the ZIP with the positive Poisson distribution
pp = vglm(y ~ 1, pospoisson, subset=y>0, tr=TRUE, crit="c")
coef(pp)
Coef(pp)
coef(fit1) - coef(pp) # Same
head(fitted(fit1) - fitted(pp)) # Different
# Another example ------------------------------
y = 0:7 # Data from Angers and Biswas (2003)
w = c(182, 41, 12, 2, 2, 0, 0, 1)
y = y[w>0]
w = w[w>0]
yy = rep(y,w)
fit3 = vglm(yy ~ 1, yip88(n=length(yy)), subset=yy>0, trace=TRUE, crit="c")
fit3@misc$phi # Estimate of phi (they get 0.5154 with standard error 0.0707)
coef(fit3, matrix=TRUE)
Coef(fit3) # Estimate of lambda (they get 0.6997 with standard error 0.1520)
head(fitted(fit3))
mean(yy) # compare this with fitted(fit3)
Run the code above in your browser using DataLab