0
$\begingroup$
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?

$\endgroup$
2
$\begingroup$

How is gender coded? Your use of prec[gender[i]+1] looks problematic. Try something like

situps[i]~dnorm(mu[i],tau[i])
tau[i] <- prec[gender[i]] # or some similar function
mu[i]<-b0+b1[gender[i]]+b2[health[i]]+b1b2[health[i],gender[i]]

NB you don't need the semi-colons at the end of each line

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.