Holds replicated datasets from a KaguModel's $prior_predictive() or
$posterior_predictive() alongside the observed data. $y() and $yrep()
return data in the shapes the bayesplot package expects (a vector and a
[draws, observations] matrix), so any bayesplot::ppc_*() function works
directly:
pp <- model$posterior_predictive()
bayesplot::ppc_dens_overlay(pp$y("y"), pp$yrep("y")[1:50, ])$summary() reports predictive p-values for summary statistics, and
$cor_check() / $plot_cor() compare the correlation between every pair of
variables with what the model reproduces - a whole-graph check (for joint
and prior results) with no direct bayesplot equivalent.
Public fields
typeCharacter -
"prior","conditional"or"joint".dataThe observed
data.frame.replicatesNamed list of
[ndraws, n]matrices, one per node.dagThe model's DAG.
Methods
PredictiveResult$new()
Create a PredictiveResult (normally via a KaguModel).
Usage
PredictiveResult$new(type, data, replicates, dag)PredictiveResult$summary()
Predictive p-values for summary statistics.
For each node and statistic T, compares T(y) with the distribution of
T(yrep) over the replicated datasets. p_value = Pr(T(yrep) >= T(y)):
values near 0 or 1 mean the observed statistic is extreme relative to
what the model generates.
Usage
PredictiveResult$summary(
stats = c("mean", "sd", "min", "max"),
nodes = NULL,
prob = 0.9
)PredictiveResult$cor_check()
Compare observed pairwise correlations with replicated ones.
A whole-graph check: under a joint (or prior) predictive, each replicated
dataset carries the dependence structure the DAG implies, so a pair whose
observed correlation falls outside its replicated range points to a
missing (or spurious) edge or a misspecified mechanism. Not available for
conditional results, whose nodes are simulated separately.
Arguments
probNumeric - probability mass of the replicate interval.
methodCorrelation method passed to
stats::cor().
PredictiveResult$plot_cor()
Plot $cor_check(): each pair's replicated correlation
interval with the observed value; pairs outside their interval are
highlighted.
Arguments
probNumeric - probability mass of the replicate interval.
methodCorrelation method passed to
stats::cor().