Recommended way of making posterior predictive checks available in Stan based packages

Is there a recommended way of making posterior predictive checks available in Stan based packages? I looked around a bit and got the impression that the one should already generate the predicted values in the generated quantities block so that one just needs to compare them to the actual observed values.

Is that the recommended way? Or should this be done differently (e.g. only retain the parameter values and e.g. work through an exposed _rng function)?

I would look at what is done in the bayesplot package and import the relevant generics from the rstantools package. We generally recommend doing posterior predictive stuff in R, rather than in generated quantities, so that the user has an option to use only a random subset of the realizations.

2 Likes

I guess that depends on which one of us you ask. I’d prefer to keep everything in Stan. We’re going to expose a way to take draws and run them through a Stan generated quantities block without rerunning. That should allow everything to stay in Stan without having to duplicate all of our functionality on the outside. On the other hand, if your posterior needs something not in Stan, the only way to do it will be externally.

2 Likes