model{
## Likelihood
for(i in 1:n){
y[i] ~ dnegbin(p[i],r)
p[i] <- r/(r+(1-zero[i])*lambda.count[i]) - 1e-10*zero[i]
lambda.count[i] <- exp(mu.count[i])
mu.count[i] <- beta00 + beta1*x[i] + beta2*r2[i] +beta3*r3[i] +beta4*r4[i]
## Zero-Inflation
zero[i] ~ dbern(pi[i])
pi[i] <- ilogit(mu.binary[i])
mu.binary[i] <- alpha00 + alpha11*x[i]
}
## Priors
beta00 ~ dnorm(0,0.0001)
beta1 ~ dnorm(0,0.0001)
beta2 ~ dnorm(0,0.0001)
beta3 ~ dnorm(0,0.0001)
beta4 ~ dnorm(0,0.0001)
alpha00 ~ dnorm(0,0.0001)
alpha11 ~ dnorm(0,0.0001)
r ~ dunif(0,50)
}