Quantcast
Viewing all articles
Browse latest Browse all 205372

Possible directed cycle in JAGS

I am trying to fit a space state model, and I am getting this error message:

Error in jags.model(file = model.file, data = data, inits = inits, n.chains = n.chains,  : 
  RUNTIME ERROR:
Possible directed cycle involving some or all
of the following nodes:
t[2]
t[3]
t[4]
t[5]
t[6]
t[7]
t[8]
t[9]
v[2]
v[3]
v[4]
v[5]
v[6]
v[7]
v[8]
v[9]


I`ve found here JAGS error - Possible directed cycle involving some or all of the following nodes that it might be due to the term t[i] which is in both sides of the equation but I have done this before in other space states models and I have no problem with this, any idea of what can be causing this problem??? Here is the model:

o<-c(22.77619, 19.07782, 22.08817, 16.32168, 32.57081, 10.48027, 15.93440, 27.54557, 33.39933)

cat(file="pop.din","
model {
  t[1] <- n0
  o[1] ~ dlnorm(log(t[1]),tau.obs)
  for (i in 2:9) {
  v[i] <- lambda*t[i] #valor esperado
  t[i] ~ dpois(v[i])  #t valor verdadero
  o[i] ~ dlnorm(log(t[i]),tau.obs)
  }
  lambda ~ dunif(0.1,0.00001)
  tau.obs ~ dgamma(1,10)
  n0 ~ dlnorm(1,0.0001)
}")

pop.din.data<-c("o")

#initial values for the parameters stored as a list
inits<-function()list(lambda=runif(0.01,1),tau.obs=rlnorm(1,1,1),n0=rlnorm(1,1,1))

params<- c("lambda","n0","tau.obs")

ni <- 10000
nt <- 1
nb <- 5000
nc <- 3


library(jagsUI)
j.model   <- jags (model.file = "pop.din", data = pop.din.data,parameters.to.save = params,
                   inits=inits, n.burnin=nb,n.chains = nc,n.iter = ni)


print(j.model)

Regards


Viewing all articles
Browse latest Browse all 205372

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>