Prior ordering with multivariate distribution

Help
Re
2010-11-30
2012-09-01
  • Re
    Re
    2010-11-30

    I am trying to run the following WinBUGS code in JAGS,

    WinBUGS code

    model {

    for (i in 1:N) {

    S ~ dmnorm(mu[Z_, 1:T], tau[Z_, 1:T, 1:T])

    Latent status

    Z_ ~ dcat(Pi)

    }

    Priors

    Pi <- 1 - Pi

    Pi ~ dbeta(13.3221, 6.2809)

    Priors on means

    for(t in 1:T) {

    mu ~ dnorm(0, 0.01)I(mu, )

    mu ~ dnorm(0, 0.01)I(, mu)

    }

    Priors on precision matrix

    for (m in 1:M) {

    tau ~ dwish(A, 10)

    }

    }

    Data

    list(M = 2, T = 3, N = 658, A = structure(.Data = c(

    0.001, 0, 0,

    0, 0.001, 0,

    0, 0, 0.001

    ), .Dim = c(3, 3)),

    S = structure(.Data = c(...))

    and I have replaced the "Priors on means" section with

    Priors on means

    for(t in 1:T) {

    for(m in 1:M) {

    unsorted.mu ~ dnorm(0, 0.01)

    }

    mu <- sort(unsorted.mu)

    }

    to be able to run it in JAGS. However, it gives wrong results such that most
    precisions 'tau's are negative.

    Q1. Can the 'sort' function in JAGS deal with multidimensional arrays?

    Q2. and how to sort the priors in descending order?


     
  • Re
    Re
    2010-11-30

    For some reason, the sourceforge has removed "" after "Z"'s in the likelihood
    when I posted the code. All "Z"'s in the likelihood must be "Z
    ".__

     
  • Re
    Re
    2010-11-30

    All Z should change to Z_i in the code.

     
  • Martyn Plummer
    Martyn Plummer
    2010-11-30

    I think you need to put your model inside a BBCode "code" block to preserve
    the formatting.

    You already know the reason why you are getting the wrong answers. In the BUGS
    version

    mu[2,t] < mu[1,t]
    

    whereas in the JAGS model

    mu[1,t] < mu[2,t]
    

    .

    You could use this to reverse the order again

                    S[i, 1:T] ~ dmnorm(mu[3 - Z[i], 1:T], tau[Z[i], 1:T, 1:T])