jeromyanglim / JAGS_by_Example

A set of JAGS examples implementing Bayesian modelling
11 stars 5 forks source link

Modelling data as mixture of two normal distributions #10

Open jeromyanglim opened 12 years ago

jeromyanglim commented 12 years ago

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.

jeromyanglim commented 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: