BUGS friends,
I will apologize in advance for code that may seem potentially odd. I am
both a neophyte Bayesian and a neophyte Bugs user, and generally I learn by
doing. Unfortunately at this point, my learning has ceased and physical
damage to my computer is imminent.
I am trying to fit a mixture Markov model in which each of i "individuals"
may fall into one of three unknown classes; this class then determines
which Markov transition matrix (9x9) is in order.
I have done my best to turn this into Bugs code, but after compiling, when
I go to update I immediately get a window (I'm using WinBUGS) of mostly
gibberish with the title "Trap 0". It's difficult to tell, but I think the
issue has something to do either with my indexing or with the way that I've
specified the Dirichlet prior, but I've tried to correct both through lot's
of consideration and sheer brute force, and am getting nowhere.
In the hopes that one of you will be able to help me out, I have included
my code below:
model
{
for (i in 1:I)
{
Y[i,1]~dcat(ypi[h[i],state0[i],1:M])
for (t in 2:T)
{
Y[i,t]~dcat(ypi[h[i],Y[i,t-1],1:M])
}
h[i]~dcat(hpi[i,1:K])
for (k in 1:K)
{
hpi[i,k]<-phi[i,k]/sum(phi[i, ])
log(phi[i,k])<-int[k]+hbeta1[k]*utl3[i]
}
}
for (n in 1:N)
{
matrix1[n,1:M]~ddirch(alpha[1:M])
matrix2[n,1:M]~ddirch(alpha[1:M])
matrix3[n,1:M]~ddirch(alpha[1:M])
for (m in 1:M)
{
ypi[1,n,m]<-matrix1[n,m]
ypi[2,n,m]<-matrix2[n,m]
ypi[3,n,m]<-matrix3[n,m]
}
}
for (m in 1:M)
{
alpha[m]<-1/9
}
hbeta1[1:K]~dnorm(0,0.001)
int[1:K]~dnorm(0,0.001)
}
Any help would be greatly appreciated.
Thanks,
David Thoms
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|