Skip to contents

Plot the density of the observed data over the densities of replicate datasets simulated from the fitted model, to check that the model reproduces its data.

Usage

# S3 method for class 'kb_fit'
pp_check(object, type = c("response", "residual"), ..., ndraws = 50L)

Arguments

object

A kb_fit object.

type

A string, one of "response" (the recorded response) or "residual" (deviance residuals), specifying what to compare.

...

These dots are for future extensions and must be empty.

ndraws

A whole number of replicate datasets to draw, at most the number of draws in the fit.

Value

A ggplot object from bayesplot::ppc_dens_overlay().

Details

Each replicate is simulated at the observed rows from one random posterior draw, so set a seed with set.seed() for a reproducible plot. For a fit made with prior_only = TRUE, the plot is a prior predictive check. See the Advanced article for how to read it.

See also

Examples

set.seed(1)
pp_check(fit_weight_sim_nereo)

pp_check(fit_size_sim_nereo, "residual", ndraws = 20)