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 :
Poisson_model<-"
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