Hi Seyab,

In any variety of BUGS (WinBUGS, OpenBUGS, JAGS) the Dirichlet distribution can be used as prior but NOT as likelihood.
If you need to estimate the parameters of the Dirichlet, you need to use a different parametrization, for example by using a sum of
exponentials. See my example below.

Kind regards,

Pablo


model {
for(i in 1:14)
{
g1[i] <- 1
g2[i] <- 1
 }
 
for(i in 1:14)
{
theta1[i] ~ dexp(g1[i])
theta2[i] ~ dexp(g2[i])
         a[i] <- theta1[i] / V1
         b[i] <- theta2[i] / V2
}

V1 <- sum(theta1[])
V2 <- sum(theta2[])

   for(i in 1:14) {
      y1m[i] <- (a[i] + 60*b[i])/61
      y2m[i] <- (a[i] + 29*b[i])/30

   }
   y1[1:14] ~ dmulti(y1m[1:14], 61)
   y2[1:14] ~ dmulti(y2m[1:14], 30)
}

list(
   y1 = c(3,0,1,2,4,1,2,0,25,11,3,0,4,5),
   y2 = c(2,1,0,1,1,0,1,2,6,2,4,3,7,0)
)




Am 11.02.2016 um 02:57 schrieb Seyab Krowten:
[log in to unmask]" type="cite">
Hi All,

I have a fairly simple model and data as shown below.  Everything is okay until I update the model, at which point I get the following error:

update error for node <a[1]> algorithm non conjugate dirichlet updater error can not sample node  too many iterations

If you see my mistake I'd greatly appreciate your help.

Some background on the inference problem I have...  I have two urns, each filled with balls labeled 1:14.  Each urn has a different distribution.  I have conducted two experiments that lead to my observed data.  In the first experiment, I draw exactly one ball from urn A and 60 balls from urn B, but I do not know which ball came from which urn, only the final count of each label 1:14.  In the second experiment I again draw exactly one ball from urn A, but draw 29 balls from urn B.  Again, I only know the final counts.  I want to infer the underlying distribution of labeled balls in each urn.

Thanks,
Seyab


model {
   theta <-1 
   for(i in 1:14) {
      alpha[i] <- theta
   }
   a[1:14] ~ ddirich(alpha[])
   b[1:14] ~ ddirich(alpha[])

   for(i in 1:14) {
      y1m[i] <- (a[i] + 60*b[i])/61
      y2m[i] <- (a[i] + 29*b[i])/30
   }
   y1[1:14] ~ dmulti(y1m[],61)
   y2[1:14] ~ dmulti(y2m[],30)
}

list(
   y1 = c(3,0,1,2,4,1,2,0,25,11,3,0,4,5),
   y2 = c(2,1,0,1,1,0,1,2,6,2,4,3,7,0)
)

modelCheck("bugs.model")
model is syntactically correct

modelData("bugs.data")
data loaded

modelCompile(1)
model compiled

modelGenInits()
initial values generated, model initialized

modelUpdate(10000)
update error for node <a[1]> algorithm non conjugate dirichlet updater error can not sample node  too many iterations 

------------------------------------------------------------------- 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

------------------------------------------------------------------- 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