
model
{
  # Likelihood
  for( t in 1:Today ){
    for(d in 0:D){
      n[t,(d+1)] ~ dpois(lambda[t,(d+1)])
      log(lambda[t,(d+1)]) <- alpha[t] + beta.logged[(d+1)] + inprod(X[t, 1:6], gamma)
    }
    sum.n[t] <- sum(n[t,]) + m[t]
    sum.lambda[t] <- sum(lambda[t,])
  }
  # Prior for alpha
  alpha[1] ~ dnorm(alpha1.mean.prior, alpha1.prec.prior)
  for( t in 2:Today ){
    alpha[t] ~ dnorm(alpha[t-1],tau2.alpha)
  }
  # Prior for beta
  beta.logged <- log(beta)
  beta ~ ddirch(beta.priors)

  # Priors for gamma (day-of-week covariate effects)
  # Estimate only 6 coefficients, excluding the last (Sunday) which is fixed as 0 for reference
  for(j in 1:6) {
    gamma[j] ~ dnorm(gamma.mean.prior[j], gamma.prec.prior[j])
  }
  
  # Prior for variance
  tau2.alpha ~ dgamma(alphat.shape.prior,alphat.rate.prior)
}