### WinBUGS dynamic modeling

# Prior

InvVe[1:T,1:3]~dwish(R[,],3)

acent[1]~dnorm(0.0,0.0001)

acent[2]~dnorm(50,0.0001)

acent[3]~dnorm(100,0.0001)

for ( j in 1:3) {

b[ j ]~dnorm(0.0,0.001)

gacent[ j ]~dgamma(0.001,0.001)

gb[ j ]~dgamma(0.001,0.001) }

# Likelihood

# Draw the T intercepts and slopes for each batch

for ( i in 1:B) {

for ( j in 1:3) {

alpha[i, j] ~ dnorm(acent[ j ], gacent[ j ])

beta[i, j] ~ dnorm(b[ j ], gb[ j ]) } }

# Draw vector of results from each tablet

for (obs in 1:N){

for ( j in 1:3){

mu[obs,j]<-alpha[Batch[obs],j]+beta[Batch[obs],j]*(Month[obs]-xbar)}

y[obs,1:T ]~dmnorm(mu[obs, ], InvVe[ , ])}