I am currently learning to use JAGS with rjags. I am starting by trying to
replicate some of the WinBUGS code and results from Royle and Dorazio's
Hierarchical Modeling and Inference in Ecology. The current model I am trying
to fit is a fairly simple hierarchical logistic regression. I am getting
stumped by an error message:
Error in node y
Observed node inconsistent with unobserved parents at initialization
At other times the error has occured in y or y, but these three nodes are the
first 3 non-zero nodes in the y variable. The model specification I am using
is:
In your code you are randomly initializing the latent variable z to be 0 or 1.
But if z = 0 then y = 0. The problem arises because you've got some non-zero y
values with zero z.
To fix the code, modify your initial values for z from this
z=rbinom(M,1,.4)
to this
z=ifelse(y>0, 1, rbinom(M, 1, 0.4))
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
I am currently learning to use JAGS with rjags. I am starting by trying to
replicate some of the WinBUGS code and results from Royle and Dorazio's
Hierarchical Modeling and Inference in Ecology. The current model I am trying
to fit is a fairly simple hierarchical logistic regression. I am getting
stumped by an error message:
Observed node inconsistent with unobserved parents at initialization
At other times the error has occured in y or y, but these three nodes are the
first 3 non-zero nodes in the y variable. The model specification I am using
is:
I have posted my r code and the data here:
https://public.me.com/pokey54
Any help in interpreting or troubleshooting this error is appreciated.
Thanks!
In your code you are randomly initializing the latent variable z to be 0 or 1.
But if z = 0 then y = 0. The problem arises because you've got some non-zero y
values with zero z.
To fix the code, modify your initial values for z from this
to this