`PPC-overview.Rd`

The **bayesplot** PPC module provides various plotting functions for creating
graphical displays comparing observed data to simulated data from the
posterior (or prior) predictive distribution. See below for a brief
discussion of the ideas behind posterior predictive checking, a description
of the structure of this package, and tips on providing an interface to
**bayesplot** from another package.

The idea behind posterior predictive checking is simple: if a model is a good fit then we should be able to use it to generate data that looks a lot like the data we observed.

`y`

argument to the PPC plotting functions can be
used to provide plausible or implausible `y`

values that you want to compare
to the prior predictive realizations.
The plotting functions for prior and posterior predictive checking are organized into several categories, each with its own documentation:

Distributions: Histograms, kernel density estimates, boxplots, and other plots comparing the empirical distribution of data

`y`

to the distributions of individual simulated datasets (rows) in`yrep`

.Statistics: The distribution of a statistic, or a pair of statistics, over the simulated datasets (rows) in

`yrep`

compared to value of the statistic(s) computed from`y`

.Intervals: Interval estimates of

`yrep`

with`y`

overlaid. The x-axis variable can be optionally specified by the user (e.g. to plot against against a predictor variable or over time).Predictive errors: Plots of predictive errors (

`y - yrep`

) computed from`y`

and each of the simulated datasets (rows) in`yrep`

. For binomial models binned error plots are also available.Scatterplots: Scatterplots (and similar visualizations) of the data

`y`

vs. individual simulated datasets (rows) in`yrep`

, or vs. the average value of the distributions of each data point (columns) in`yrep`

.Plots for discrete outcomes: PPC functions that can only be used if

`y`

and`yrep`

are discrete. For example, rootograms for count outcomes and bar plots for ordinal, categorical, and multinomial outcomes.LOO predictive checks: PPC functions for predictive checks based on (approximate) leave-one-out (LOO) cross-validation.

In addition to the various plotting functions, the **bayesplot** package
provides the S3 generic `pp_check()`

. Authors of R packages for
Bayesian inference are encouraged to define `pp_check()`

methods for the
fitted model objects created by their packages. See the package vignettes for
more details and a simple example, and see the **rstanarm** and **brms**
packages for full examples of `pp_check()`

methods.

Gabry, J. , Simpson, D. , Vehtari, A. , Betancourt, M. and
Gelman, A. (2019), Visualization in Bayesian workflow.
*J. R. Stat. Soc. A*, 182: 389-402. doi:10.1111/rssa.12378.
(journal version,
arXiv preprint,
code on GitHub)

Gelman, A., Carlin, J. B., Stern, H. S., Dunson, D. B., Vehtari,
A., and Rubin, D. B. (2013). *Bayesian Data Analysis.* Chapman & Hall/CRC
Press, London, third edition. (Ch. 6)

Other PPCs: `PPC-discrete`

,
`PPC-distributions`

,
`PPC-errors`

, `PPC-intervals`

,
`PPC-loo`

, `PPC-scatterplots`

,
`PPC-test-statistics`