0

I'm trying to fit a simplex model with poisson trick, the likelihood is Likelihood Simplex. The code is below

model{
  for (i in 1:n){
    y[i] ~ dpois(lambda[i])
    lambda[i] <- 0.5*log(phi[i]*(y[i]*(1-y[i]))^3) + 0.5*(1/phi[i])*d[i]
    d[i] <- ((y[i]-mu[i])^2)/(y[i]*(1-y[i])*mu[i]^2*(1-mu[i])^2)
    mu[i] <- beta0+beta1*income[i] + beta2*person[i]
    log(phi[i]) <- -delta0
  }
  beta0 ~ dnorm(0,.001)
  beta1 ~ dnorm(0,.001)
  beta2 ~ dnorm(0,.001)
  delta0 ~ dnorm(0,.001)
}"

When I try to run the code with JAGS in R, I get the following error

 RUNTIME ERROR:
Possible directed cycle involving some or all
of the following nodes:

Then it shows all d[], y[] and lambda[]

I found that someone have a similar problem JAGS error, but looks like that I'm not doing the same mistake.

Any help?

EDIT:

Second attempt

regmodel = "
data{
  for(i in 1:n) {
    zeros[i] <- 0
  }
}
model{
  C <- 1000
  for (i in 1:n){
    zeros[i] ~ dpois(lambda[i])
    lambda[i] <- -l[i] + C
    l[i] <- 
      0.5*log(phi[i]*(y[i]*(1-y[i]))^3) + 
      0.5*(1/phi[i])*((y[i]-mu[i])^2)/(y[i]*(1-y[i])*mu[i]^2*(1-mu[i])^2)
    mu[i]<- beta0 + beta1*income[i] + beta2*person[i]
    log(phi[i]) <- -delta0
  }
  beta0 ~ dnorm(0,.001)
  beta1 ~ dnorm(0,.001)
  beta2 ~ dnorm(0,.001)
  delta0 ~ dnorm(0,.001)
}"

But the error now is

Error in jags.model(file = "ModeloSimplex.txt", data = reg.dat, n.chains = 3,  : 
  Error in node (a(a0.5*(a1/phi[1])*(a(ay[1]-mu[1])^2))/(ay[1]*(a1-y[1])*(amu[1]^2)*(a(a1-mu[1])^2)))
Invalid parent values
Marcelo Ventura
  • 581
  • 7
  • 19
Roland
  • 334
  • 2
  • 21

0 Answers0