Tiempos de estudio. Tomado de Hoff (2009, A First Course in Bayesian Statistical Methods).
The files school1.dat through school8.dat give weekly hours spent on homework for students sampled from eight different schools. Obtain posterior distributions for the true means for the eight different schools using a hierarchical normal model (with specific means and common variance) using the following prior parameters: \[
\mu_0 = 7, \gamma^2_0
= 5, \tau^2_0 = 10, \eta_0 = 2, \sigma_0^2 = 15, \nu_0 = 2.
\]
- Run a Gibbs sampling algorithm to approximate the posterior distribution of \(\boldsymbol{\theta}, \sigma^2,\mu,\tau^2\). Assess the convergence of the Markov chain, and find the effective sample sizes for all the model parameters. Run the chain long enough so that the effective sample sizes are all above \(1,000\).
- Compute posterior means and 95% confidence regions for \(\sigma^2,\mu,\tau^2\). Also, compare the posterior densities to the prior densities, and discuss what was learned from the data.
- Plot the posterior density of \(R = \tau^2/(\sigma^2+\tau^2)\) and compare it to a plot of the prior density of \(R\). Describe the evidence for between-school variation.
- Obtain the posterior probability that \(\theta_7\) is smaller than \(\theta_6\), as well as the posterior probability that \(\theta_7\) is the smallest of all the \(\theta\)s.
- Plot the sample averages \(\bar{y}_1,\ldots,\bar{y}_8\) against the posterior expectations of \(\theta_1,\ldots,\theta_8\), and describe the relationship. Also compute the sample mean of all observations and compare it to the posterior mean of \(\mu\).
- Repeat all the previous items using a hierarchical model with both specific means and variances per group. Elicitate the prior parameters for the variance components mantaining the same prior knowledge about the specific variances in average.