Re
2010-11-30
I am trying to run the following WinBUGS code in JAGS,
model {
for (i in 1:N) {
S ~ dmnorm(mu[Z_, 1:T], tau[Z_, 1:T, 1:T])
Z_ ~ dcat(Pi)
}
Pi <- 1 - Pi
Pi ~ dbeta(13.3221, 6.2809)
for(t in 1:T) {
mu ~ dnorm(0, 0.01)I(mu, )
mu ~ dnorm(0, 0.01)I(, mu)
}
for (m in 1:M) {
tau ~ dwish(A, 10)
}
}
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
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
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
2010-11-30
All Z should change to Z_i in the code.
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])