# NOT RUN {
set.seed(50)
n=100
dat <- data.frame(y=rbinom(n, 1, 0.5)*rpois(n, 1.2), x1=runif(n), x2=runif(n), z=runif(n))
# poisson count model, mixture in both portions
# }
# NOT RUN {
# warning: the examples below can take a long time to run
res = qgcomp.zi.boot(f=y ~ x1 + x2 | x1 + x2, expnms = c('x1', 'x2'),
data=dat, q=4, dist="poisson", B=1000, MCsize=10000, parallel=TRUE)
qgcomp.zi.noboot(f=y ~ x1 + x2 | x1 + x2, expnms = c('x1', 'x2'),
data=dat, q=4, dist="poisson")
res
# accuracy for small MCsize is suspect (compare coefficients between boot/noboot versions),
# so re-check with MCsize set to larger value (this takes a long time to run)
res2 = qgcomp.zi.boot(f=y ~ x1 + x2 | x1 + x2, expnms = c('x1', 'x2'),
data=dat, q=4, dist="poisson", B=1000, MCsize=50000, parallel=TRUE)
res2
plot(density(res2$bootsamps[4,]))
# negative binomial count model, mixture and covariate in both portions
qgcomp.zi.boot(f=y ~ z + x1 + x2 | z + x1 + x2, expnms = c('x1', 'x2'),
data=dat, q=4, dist="negbin", B=10, MCsize=10000)
# }
Run the code above in your browser using DataLab