Question

I am fitting count data to Generalized Poisson distribution in JAGS,using the zeros-ones trick. I am following codes in the "Bayesian Modeling Using WinBUGS" book(page 286).Here are my codes:

GPoisson.model <- function(){
C <- 10000
for(i in 1:N){
    zeros[i] <- 0
    zeros[i] ~ dpois(zeros.mean[i])
    zeros.mean[i] <- -l[i] + C
    #log-likelihood 
    lambda.star[i] <- (1-omega)*lambda[i] + omega*y[i]
    l[i] <- log((1-omega)*lambda[i]) + (y[i]-1)*log(lambda.star[i]) -
    loggam(y[i]+1) - lambda[i]
    #log-link + linear predictor
    log(lambda[i]) <- log(E[i]) + inprod(X[i,],beta[])
    }
#priors
omega ~ dbeta(1,1)
for(j in 1:17){
    beta[j] ~ dnorm(0,0.001)
}

}

When I run the model I got this error:

Compilation error on line 6.
Attempt to redefine node zeros[1]

I still don't understand what is wrong with zeros[i]. Enlighten me please. Thanks in advance.

Was it helpful?

Solution

Your lines

     zeros[i] <- 0
     zeros[i] ~ dpois(zeros.mean[i])

cause a problem. In JAGS you can't redefine the given value of a variable. I think you should drop the line:

 zeros[i] <- 0

from your code

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top