quivers.diagnostics.predictive_checks¶
Posterior-predictive p-values and LOO-PIT calibration.
predictive_checks
¶
Posterior-predictive checks (PPCs) and calibration diagnostics.
ArviZ ships arviz.plot_ppc, arviz.loo_pit, and a
broad family of PPC visualisations. This module exposes a small
typed surface that delegates to those, and adds a registry of
common test statistics that map cleanly onto quivers' plate-and-
group structure (per-Verb mean, per-Subject sd, etc.).
STATISTICS
module-attribute
¶
STATISTICS: dict[str, Callable[[ndarray], float]] = {'mean': lambda y: float(np.mean(y)), 'median': lambda y: float(np.median(y)), 'sd': lambda y: float(np.std(y)), 'var': lambda y: float(np.var(y)), 'min': lambda y: float(np.min(y)), 'max': lambda y: float(np.max(y)), 'q05': lambda y: float(np.quantile(y, 0.05)), 'q95': lambda y: float(np.quantile(y, 0.95))}
The built-in scalar test statistics T(y) -> scalar, keyed by the
name posterior_predictive_check accepts for its statistic argument.
posterior_predictive_check
¶
posterior_predictive_check(idata: DataTree, *, observed_name: str, statistic: str | Callable[[ndarray], float] = 'mean', by: str | None = None) -> Mapping[str, float | ndarray | str]
Compute a posterior-predictive p-value (PPP-value) for a user-chosen test statistic.
| PARAMETER | DESCRIPTION |
|---|---|
idata
|
Fit produced by
TYPE:
|
observed_name
|
Name of the observed site (must appear in both groups).
TYPE:
|
statistic
|
Either a key into
TYPE:
|
by
|
If given, computes the statistic per group along the named
dim (e.g.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Mapping[str, float or ndarray]
|
|
Source code in src/quivers/diagnostics/predictive_checks.py
loo_pit
¶
Leave-one-out probability-integral-transform calibration.
Delegates to arviz.loo_pit. The canonical use of the PIT values
is arviz.plot_loo_pit for the calibration diagnostic plot.
| PARAMETER | DESCRIPTION |
|---|---|
idata
|
Fit produced by
TYPE:
|
observed_name
|
Name of the observed site, which must appear in those groups.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Dataset
|
The LOO-PIT value at each observed data point, under the
variable |