Print

Print


Many thanks to Sanjib. I never imagined inserting the negative sign
would pose a problem.

Solution:
-------------------
Raphael:

   I ran your code.

    The issue is not with the Uniform distribution, but with "- u[j]"
as arithmetic expressions are not allowed within a distribution
specification. I ran the following revision of your code up to 1000
iterations.

   model {

        for (j in 1:M) {

                        U[j] ~ dunif(u1[j],u[j])


                        K[j] ~ dcat(p[1:N])

                        u1[j] <- -u[j]


                        u[j] <- r[K[j]]


On Wed, Sep 26, 2012 at 5:02 AM, Raphael Fraser <[log in to unmask]> wrote:
>
> Hi,
>
> My goal is to sample from a mixture of uniforms but unless U[j] is observed or u[j] is a number my code will not work. Is there an alternative? Can anyone help?
>
> Thanks,
> Raphael
>
> model {
>
>         for (j in 1:M) {
>
>                         U[j] ~ dunif(-u[j],u[j])
>                         K[j] ~ dcat(p[1:N])
>                         u[j] <- r[K[j]]
>
>                         for (i in 1:N) {
>                                 SC[j,i] <- equals(i,K[j])
>                         }
>                 }
>
>                         for (i in 1:N) {
>                                 sumSC[i] <- sum(SC[,i])
>                                 cl[i] <- step(sumSC[i] - 1)
>                         }
>
>                         NC <- sum(cl[])
>
>         # Contructive DPP
>         for (k in 1:N) { r[k] ~ dgamma(1.5,tau.e) }
>         for (k in 1:(N-1)) { V[k] ~ dbeta(1,1) }
>         for (k in 2:N) { p[k] <- V[k]*(1-V[k-1])*p[k-1]/V[k-1] }
>         V[N] <- 1
>         p[1] <- V[1]
>
>         # priors
>         tau.e <- pow(2*pow(sig.e,2),-1)
>         sig.e ~ dunif(0,6)
>
> }
>
> #### INITS
> list(sig.e=3.0)
>
> #### DATA
> list(M=10,N=5)
>
> ------------------------------------------------------------------- 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
>
> --
> Sanjib Basu
>
>
>

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