# “Array index is less than one” WINBUGS Error

for (i in 1:160) {
situps[i] ~ dnorm(mu[i],prec[gender[i]+1]);
mu[i] <- b0+b1[gender[i]]+b2[health[i]]+b1b2[health[i],gender[i]];
}
b0 ~ dnorm(0,.001);
for (i in 1:4) {
b2[i] ~ dnorm(0,.001);
}
for (j in 1:2) {
b1[j] ~ dnorm(0,.001);
prec[j] <- pow(sigma[j],-2);
sigma[j] ~ dunif(0,10);
}
for (i in 1:4) {
for (j in 1:2) {
b1b2[i,j] ~ dnorm(0,.001);
}
}


I'm not sure why this gives me the error "array index is less than one" because I clearly have all of my arrays starting at 1. Any ideas?

How is gender coded? Your use of prec[gender[i]+1] looks problematic. Try something like
situps[i]~dnorm(mu[i],tau[i])

• Indexing with gender[i] + 1 doesn't seem as problematic as indexing with gender[i] and health[i] in this case. – Tomas Jul 6 '12 at 5:40