// saved as 8schools.stan data { int J; // number of schools real y[J]; // estimated treatment effects real sigma[J]; // standard error of effect estimates } parameters { real mu; // population treatment effect real tau; // standard deviation in treatment effects vector[J] eta; // unscaled deviation from mu by school } transformed parameters { vector[J] theta = mu + tau * eta; // school treatment effects } model { eta ~ normal(0,1); // prior y ~ normal(theta, sigma); //likelihood }