samedi 31 janvier 2015

For loop reverse order JAGS

I am trying to figure out how to avoid to enter this for loop without using an IF sentence (not present in JAGS).


In other words, I need this loop not to run in reverse order, i.e. when Je[i] - 1 is smaller than 2.



for (j in 2:(Je[i]-1)){
Z[i,j] ~ dnegbin(p[i,j],r[eta[i,j]])
logit(p[i,j]) <- B1[eta[i,j]] + B2*sum(Z[i,1:j-1])
}


When Je[i] - 1 == 1, the loop still runs but in reverse order, so j is first equal to 2 and in the second iteration j is equal to 1.


Does anyone know how to fix this?


Aucun commentaire:

Enregistrer un commentaire