Open jeromyanglim opened 12 years ago
I have since learnt that this problem is called the 'label switching problem'. The issue is discussed with links in this question on CrossValidated.
This tutorial from a course on Bayesian and Modern Data analysis by Merlise Clyde
They suggest the following bugs model code:
for( i in 1 : N ) {
y[i] ~ dnorm(mu[i], tau)
mu[i] <- lambda[T[i]]
T[i] ~ dcat(pi[])
}
pi[1:2] ~ ddirch(alpha[])
theta ~ dnorm(0.0, 1.0E-6)%_%I(0.0, )
lambda[1] ~ dnorm(0.0, 1.0E-6)
lambda[2] <- lambda[1] + theta
tau ~ dgamma(0.001,0.001)
sigma <- 1 / sqrt(tau)
Notes on the above code:
lambda
is a vector of length 2 that stores the mean for the first and second
groupslamba
two as greater than lambda
by the quantity theta
; and theta
is
constrained to be greater than zero through the use of the I
notationT[i]
stores a vector with length equal to the number of observations N
,
and made up of values of 1 and 2, thereby permitting the extraction of group
means for each case lambda[T[i]]
.
My first attempt had issues. In particular, mu1 and mu2 had the posterior distributions eventhough conceptually I wanted to somehow think of mu1 as the lower group mean and mu2 as the higher group mean.