# Bugs model file for 8 schools analysis from Section 5.5 of "Bayesian Data
# Analysis". Save this into the file "schools.bug" in your R working directory.

model {
  for (j in 1:J){                          # J=8, the number of schools
    y[j] ~ dnorm (theta[j], tau.y[j])      # data model:  the likelihood
    tau.y[j] <- pow(sd[j], -2)        # tau = 1/sigma^2
  }
  for (j in 1:J){
    theta[j] ~ dnorm (mu, tau) # hierarchical model for theta
  }
  tau <- pow(sigma, -2)        # tau = 1/sigma^2
  mu ~ dnorm (0.0, 1.0E-6)           # noninformative prior on mu
  sigma ~ dunif (0, 1000)            # noninformative prior on sigma
}
