pp_validate
function is based on the methods described in
Cook, Gelman, and Rubin (2006) for validating software developed to fit
particular Bayesian models. Here we take the perspective that models
themselves are software and thus it is useful to apply this validation
approach to individual models.
pp_validate(object, nreps = 20, seed = 12345, ...)
stanreg-objects
.nreps
must be
sufficiently large so that the statistics described below in Details are
meaningful. Depending on the model and the size of the data, running
pp_validate
may be slow. See also the Note section below for advice
on avoiding numerical issues.size
) passed to
geom_point
to control the appearance of the plot.nreps
times the process of simulating parameters and data
from the model and refitting the model to this simulated data. For each of
the nreps
replications we do the following:
prior_PD=TRUE
), obtaining draws $\theta_true$
from the prior distribution of the model parameters.
posterior_predict
on the fitted model object obtained in step
1).
For any individual parameter, the quantile of the "true" parameter value with respect to its posterior distribution should be uniformly distributed. The validation procedure entails looking for deviations from uniformity by computing statistics for a test that the quantiles are uniformly distributed. The absolute values of the computed test statistics are plotted for batches of parameters (e.g., non-varying coefficients are grouped into a batch called "beta", parameters that vary by group level are in batches named for the grouping variable, etc.). See Cook, Gelman, and Rubin (2006) for more details on the validation procedure.
pp_check
for graphical posterior predictive checks and
posterior_predict
to draw from the posterior predictive
distribution.
## Not run:
# if (!exists("example_model")) example(example_model)
# pp_validate(example_model)
# ## End(Not run)
Run the code above in your browser using DataLab