zigp.model {bayescount} | R Documentation |
Apply a Bayesian zero-inflated gamma Poisson (zero-inflated negative binomial) model to count data to return probable values for mean count, overdispersion and zero-infaltion. Usually called internally from the bayescount function, but can be called directly by the user (although there is significantly less user-proofing for using this function directly than for bayescount). Convergence is assessed by calculating the Gelman-Rubin statistic for each parameter. Requires Just Another Gibbs Sampler (JAGS). *THIS SOFTWARE IS INTENDED FOR EDUCATIONAL PURPOSES ONLY AND SHOULD NOT BE RELIED UPON FOR REAL WORLD APPLICATIONS*
zigp.model(data, name, jags = "jags", burnin = 5000, updates = 10000, log.prior = TRUE, ml.equivalent = FALSE, adjust.mean = FALSE)
data |
an existing integer vector containing the data. No default. |
name |
a name for the analysis (character string). No default. |
jags |
the system call or path for activating JAGS. Default for Linux is 'jags', in Windows try 'C:/JAGS-0.90/jags.exe' etc. |
burnin |
the number of burnin iterations (not sampled) to use (numeric). Default 5000 iterations. |
updates |
the number of sampling iterations to use (numeric). Default 10000 iterations. |
log.prior |
should the model run the model using a log uniform prior distribution for overdispersion? (logical) If FALSE, a uniform prior is used for overdispersion. Default TRUE. Where information concerning overdispersion in the data is sparse, the choice of prior distribution will have an affect on the posterior distribution for ALL parameters. It is recommended to run a simulation using both types of prior when working with small datasets, to make sure results are consistent. |
ml.equivalent |
should the function also produce results that are equivalent to the log likelihood output of many maximum likelihood models (eg. the R package 'zicounts')? (logical) If TRUE, an additional 9 columns of data are produced. Default FALSE. |
adjust.mean |
should the mean count parameter be adjusted to reflect the mean of the whole population? (logical) If FALSE the mean count of the reflects the mean of the gamma distribution only, if TRUE the mean includes extra zeros. Used for comparing results between zero-inflated and non zero-inflated models. Default FALSE. |
The results of the simulation are returned as a vector of length 14 or 23 (depending on 'ml.equivalent'), containing the following:
1 |
name |
2 |
convergence successful (1 or 0) |
3 |
model crashed (1 or 0) |
4 |
error in model (1 or 0) |
5 |
number of sampling iterations achieved |
6 |
lower 95 percent confidence interval estimate for mean count |
7 |
median estimate for mean count |
8 |
upper 95 percent confidence interval estimate for mean count |
9 |
lower 95 percent CI for zero-inflation |
10 |
median for zero-inflation |
11 |
upper 95 percent CI for zero-inflation |
12 |
lower 95 percent CI for overdispersion |
13 |
median for overdispersion |
14 |
upper 95 percent CI for overdispersion |
15 |
lower 95 percent confidence interval estimate for log(mean) |
16 |
median estimate for log(mean) |
17 |
upper 95 percent confidence interval estimate for log(mean) |
18 |
lower 95 percent CI for logit(zero-inflation) |
19 |
median for logit(zero-inflation) |
20 |
upper 95 percent CI for logit(zero-inflation) |
21 |
lower 95 percent CI for log(mean/overdispersion) |
22 |
median for log(mean/overdispersion) |
23 |
upper 95 percent CI for log(mean/overdispersion) |
Matthew Denwood m.denwood.1@research.gla.ac.uk, funded as part of the DEFRA VTRI project 0101.
bayescount
p.model
gp.model
zip.model
# run an analysis named 'test' on a dataframe object 'mydata', with all model values as default, and save the results to 'myresults': mydata <- c(5,3,7,9,5,6,2,1,6,5) myresults <- zigp.model(name="test", data=mydata)