Dear BUGS users,
 
I have a straightforward yet problematic code.
 
Please notice the  probabilities assigned to each category of the categorical variable named g in my code below. When I hit the compile button, it delivers the error message 'index out of range'.
 
I played around and found out that this error disappears and the program runs without interruption if I delete one of the 4 terms used to calculate the categorical probabilities pg[1], pg[2], pg[3].
 
I'd appreciate  a lot if someone can tell me why this is so and what I should do to get it run.
 
Thanks,
 
Dr. Zeynep Kalaylioglu
Assistant Professor,
Department of Statistics,
Middle East Technical University,
Ankara, Turkey
 
 
 
model{
 
l ~ dbern(pl)
pl <- 0.9 * equals(g,1) + 0.6 * equals(g,2) + 0.01 * equals(g,3)
 
s ~ dbern(ps)
ps <- 0.05 * equals(i,0) + 0.8 * equals(i,1)
 
g ~ dcat(pg[1:3])
pg[1] <- 0.3 * equals(i,0) * equals(d,0) + 0.05 * equals(i,0) * equals(d,1) + 0.9 * equals(i,1) * equals(d,0) + 0.5 * equals(i,1) * equals(d,1)
 
pg[2] <- 0.4 * equals(i,0) * equals(d,0) + 0.25 * equals(i,0) * equals(d,1) + 0.08 * equals(i,1) * equals(d,0) + 0.3 * equals(i,1) * equals(d,1)
 
pg[3] <- 0.3 * equals(i,0) * equals(d,0) + 0.7 * equals(i,0) * equals(d,1) + 0.02 * equals(i,1) * equals(d,0) + 0.2 * equals(i,1) * equals(d,1)
 
 
propg1 <- equals(g,1)
propg2 <- equals(g,2)
propg3 <- equals(g,3)
 
propd0 <- equals(d,0)
propd1 <- equals(d,1)
 
propi0 <- equals(i,0)
propi1 <- equals(i,1)
 
#Priors
d ~ dbern(0.4)
i ~ dbern(0.3)
 
}
INITS
list(d=0,i=1,g=2)
 
Data
list(l=0,s=1)

------------------------------------------------------------------- This list is for discussion of modelling issues and the BUGS software. For help with crashes and error messages, first mail [log in to unmask] To mail the BUGS list, mail to [log in to unmask] Before mailing, please check the archive at www.jiscmail.ac.uk/lists/bugs.html Please do not mail attachments to the list. To leave the BUGS list, send LEAVE BUGS to [log in to unmask] If this fails, mail [log in to unmask], NOT the whole list