The hierarchical model you describe is a generative model. The model you constructed can be used to generate "fake" data. This is a little different conceptually than using your model to make predictions.
The assumption underlying this concept is that a good model should generate fake data that is similar to the actual data set you used to make your model. A bad model will generate data that is in some way fundamentally or systematically different.
You can assess this visually or by using some metric, such as the pp.check method you tried in JAGS (I am not a JAGS user, so can't comment specifically on how this is implemented).
Procedurally how this works is:
You specify your model. In your case it looks like you want to do an ordinal regression. This looks like a similar example. Specifically I refer you to the chapter called "Ordinal Predicted Variable" in this book.
You sample and obtain posterior distributions for the parameters in your model. Looking at the figure in the linked example, these parameters are $\beta_0$, $\beta_1$ and $\sigma$.
Now draw posterior predictive samples. Over the range of your input (Dollars), draw many samples from the posteriors (or take the samples of your posteriors) of the parameters you estimated, then plug those samples into your model equation, the Happiness ~ log(Dollars) you wrote down.
You should end up with many samples of "Happiness" data at a given log(Dollars). From these samples you could, for instance, compute and plot 90% credible intervals across log(Dollar).
- Plot actual data (on the y axis: Happiness, on the x axis: log(Dollars)), then overlay the draws and credible intervals of your posterior predictive samples.
Now check visually. Does your 90% credible interval contain 90% of the actual Happiness data points? Are there systematic departures of the true data from your model? Then resort to metrics such as pp.check.
This is one way of performing model validation, there are many others.
I wouldn't try to pick a single y_rep_i value for each i but actually look at full distributions or summaries of the distributions. To that end, check out the bayesplot package (also from the Stan Development Team) which has a lot of functionality for PPCs and several vignettes that cover some of these concepts and provide examples. You can also get good help at Stan the forum (http://discourse.mc-stan.org)
Best Answer
Posterior predictive checks are, in simple words, "simulating replicated data under the fitted model and then comparing these to the observed data" (Gelman and Hill, 2007, p. 158). So, you use posterior predictive to "look for systematic discrepancies between real and simulated data" (Gelman et al. 2004, p. 169).
The argument about "using the data twice" is that you use your data for estimating the model and then, for checking if the model fits the data, while generally it is a bad idea and it would be better to validate your model on external data, that was not used for estimation.
Posterior predictive checks are helpful in assessing if your model gives you "valid" predictions about the reality - do they fit the observed data or not. It is a helpful phase of model building and checking. It does not give you a definite answer on if your model is "ok" or if it is "better" then other model, however, it can help you to check if your model makes sens.
This is nicely described in LaplacesDemon vignette Bayesian Inference: