Perform a mixed predictive replication for hierarchical models when prior is improper?

In the example of rat tumor in BDA chapter 5.1, the model is

y_j \sim binomial(n_j,\theta_j) \\ \theta_j \sim beta(\alpha,\beta) \\ \pi(\alpha,\beta) \propto (\alpha+\beta)^{-2/5} \\

The prior is improper, how to perform a mixed predictive replication for hierarchical models?

I think I have done the work.
The Stan codes is as follows,

generated quantities {
  array[N] real theta_rep;
  array[N] int<lower=0> y_rep;
  for (i in  1:N) {
  theta_rep[i] = beta_rng(alpha, beta);
  y_rep[i] = binomial_rng(n[i],theta_rep[i]);
  }
}
1 Like