Poisson model in R Jags - Error in Node inconsistent with parents

Hello to all the community, I checked around the web and I saw that this forum could help me.

I have a dataframe such as ;

    Orders  Time  NbBones
    1      12    21
    1      34    43
    2      32    0
    3      21    0
    42     10    0

And I wrote a jags GLM poisson model :

      for(i in 1 : N) 
        NbBones[i] ~ dpois(lambda[i])
        lambda[i] <-  alpha + Coeforder[Orders[i]]  + Coeftime * Time[i] 
      Coeforder[1] <- 0
      Coeforder[2] ~ dnorm(0,1)
      Coeforder[3] ~ dnorm(0,1) 
      Coeftime ~ dnorm(0,1) 
      alpha ~ dexp(1)  

data4jags <- list(Time = data$Time, NbBones = data$NbBones, Orders=data$Orders, N=length(data$Orders))

m1 <- jags.model(textConnection(Poisson_model), data = data4jags, n.chains = 3)

But when I run the code in R I get the following error message :

    Error in jags.model(textConnection(Model1), data = data4jags, n.chains = 3) : 
      Error in node NbBones[4]
    Node inconsistent with parents

Does someone understand where is the issue in the code ? Thanks a lot for your time

unfortunately, we can’t really help you with a JAGS model as this forum supports only Stan and related packages. You are however welcome to try rewriting the model in Stan and ask for help if you are having trouble. It also appears that your model would be well within the capabilities of the high-level interfaces for GLMs in Stan (both rstanarm - less flexible but easy to install and brms - very flexible but requires a full Stan installation), which are also supported here.

Best of luck with your model!

1 Like