I'd appreciate any help with this problem :
I want to fit a discrete transition model with a first order markovian
structure. So,if Y[i,j]=k : subject i (i=1, ..., nsubj) is in stage k (k=1,
..., nstage) at time j : j=1, ntime (assuming the same times for all
subjects), I want to write the likelihood based on conditional probabilities :
p(Y[i,j] given Y[i,j-1]).
For doing so, I've written the following Winbugs code but I'm not able to run
it properly.
I used the trick given by D. Spiegelhalter for schrinking the dimension of
matrices to 3, but I have the following message during compilation : variable
not defined or no data for ij. Could anybody help with this.
I also wanted to be sure that the coding is correct (specifically the
recursive dcat call) for such a purpose - any expert advice is very welcome.
Thanks,
Francois
Francois Vandenhende
Statistician
Eli Lilly & Co.
Belgium
Here is the code and a sample of data:
model
{
for (i in 1:nsubj){
for (j in 2:ntime){
# Calculated restricted node
ij <- (i-1) * nsubj + j
#Likelihood
Y[ij] ~ dcat( p[ij, Y[ij-1], 1:nstage] )
# Simple Model
for (k in 1:nstage){
for (l in 1:nstage){[ij-1],
p[ij,k,l] <- e[ij,k,l]/sum(e[ij,k,])
log(e[ij,k,l])<-beta[k,l]
}
}
}
}
#Priors
for (k in 1:nstage){
beta[k,1]<-0
for (l in 2:nstage){
beta[k,l]~dnorm(0,1.0E-6)
}
}
}
Data
list( nsubj=2, ntime=5, nstage=2,
Y=c(1,2,2,1,1,2,1,1,2,1))
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|