Skip to contents

Fit a Bayesian MCMC over a model, draw replicate datasets from the posterior, and compute the common posterior predictive p-values (mean / SD / skewness / min / max) plus a misfit flag. Wraps the shared C++ PosteriorPredictiveCheck.

Usage

posterior_predictive_check(
  data,
  distribution,
  sampler = "DEMCz",
  iterations = 3000L,
  output_length = 10000L,
  seed = 12345L,
  number_of_replicates = 1000L,
  thinning_interval = -1L
)

Arguments

data

numeric vector of observations (also the observed data for the p-value comparison).

distribution

distribution family name.

sampler

MCMC sampler: "DEMCz" (default), "DEMCzs", "ARWMH", or "NUTS".

iterations

number of post-warmup MCMC iterations.

output_length

number of posterior samples used to build the credible band.

seed

PRNG seed for the sampler (fixed for reproducibility).

number_of_replicates

number of posterior replicate datasets (default 1000).

thinning_interval

MCMC thinning interval; -1 (default) keeps the sampler's own default.

Value

A named list: number_of_replicates, mean_p_value, sd_p_value, skewness_p_value, min_p_value, max_p_value, and has_misfit (1 when any p-value is extreme, else 0).