How can I set up a zero-inflated poisson in JAGS?

I am trying to set up a zero-inflated poisson model in R and JAGS. I am new to JAGS and I need some guidance on how to do that.

I've been trying with the following where y[i] is the observed variable

model {
for (i in 1:I) {

y.null[i] <- 0
y.pois[i] ~ dpois(mu[i])
pro[i] <- ilogit(theta[i])
x[i] ~ dbern(pro[i])

y[i] <- step(2*x[i]-1)*y.pois[i] + (1-step(2*x[i]-1))*y.null[i]

log(mu[i]) <- bla + bla +bla + ....
theta[i] <- bla + bla + bla + ....
}

}

However this does not work as you cannot use <- on an observed variable.

Any ideas how to change/fix this? Is there an other way to set up the zero-inflated poisson model in JAGS?

Here is a simple solution using the fact that the poisson will give you zeros when the lambda parameter is zero. Note however that JAGS tends to break if lambda is exactly zero, thus the "+ 0.00001".

model {
for (i in 1:I) {

y[i] ~ dpois(mu1[i])

mu1[i] <- mu[i]*x[i] + 0.00001

x[i] ~ dbern(pro[i])
logit(pro[i]) <- theta[i]

mu[i] <- bla + bla +bla + ....
theta[i] <- bla + bla + bla + ....
}
C <- 10000 #Constant 1/0 trick

# Likelihood:
for ( i in 1:ny ) {

#Likelihood of the count model component
LikCountModel[i] <- pow(mu[i],y[i])/y_fact[i]*exp(-mu[i])

#Count model component
eta[i] <- bet0 + inprod( beta[] , B[i,] )
mu[i] <- exp(eta[i])

#ZI Component
zeta[i] <- gamm0 + inprod( gamma[] , G[i,] )
w[i] <- exp(zeta[i])/(1+exp(zeta[i]))

#1/0 Tricks: ones is a column containing only ones, with the same size of y
p[i] <- L[i] / C
ones[i] ~ dbern(p[i])

#Full likelihood expression
L[i] <- LikCountModel[i] * (1-w[i]) + equals(y[i],0)*w[i]
}

#then set your priors for all beta and gamma