model {

#model

for (t in 2:T) {
yield[t]~dnorm(a[t],tau.obs)
mu[t]<-a[t-1]
a[t]~ dnorm(mu[t], tau.state.a)
}

#prior on first coefficient

a[1] ~dnorm(0,0.001)


#other priors

tau.obs ~dgamma(0.001,0.001)
tau.state.a ~ dgamma(0.001,0.001)


V<-1/tau.obs

#Yield distribution

for (k in 1:T) {
Y[k] ~dnorm(a[k],tau.obs)
}

}