I am trying to run the following JAGS code from R. I am just showing some part of the code where the error is occurring.
for(mmm in 1 : p){
for(jj in 1 : K){
vv[jj] ~ dbeta(1,1);
}
pp[1] <- vv[1];
for (jjj in 2 : K){
pp[jjj] <- vv[jjj] * (1 - vv[jjj-1]) * pp[jjj-1]/vv[jjj-1];
}
}
The error is Attempt to redefine node vv[1]
on line 3. I am not sure why the error is occuring. Any help would be appreciated.
You have this
1:K
loop nested within your1:p
loop. So whenmmm
goes from1
to2
you are overwriting the values invv
. Without knowing more about the model there are two possible solutions.1:p
loop bymmm
.Assuming that the second answer is what you need it would look something like this: