Skip to main content

models.ppc_check()

Posterior predictive checks of any model: each test statistic of

Usage

models.ppc_check(
    observed,
    replicated,
    statistics=None,
    groups=None,
)

observed against its distribution over the replicated datasets, with the p-value P(T(y_rep) >= T(y)) (ties count half). With groups, each statistic is checked within each group.

Parameters

observed: list of float
replicated: list of list of float

One replicated dataset per posterior draw, each as long as observed.

statistics: list of str or float = ["mean", "sd", "min", "max"]

"mean", "sd", "min", "max", "proportion_zero", or a probability for that quantile.

groups: list of int = None
Each observation’s group, from 0.

Returns

list of dict
name, observed, replicated and p_value.

Examples

>>> from prospicio.models import ppc_check
>>> c = ppc_check([1.0, 3.0], [[0.0, 2.0], [2.0, 4.0], [1.0, 3.0]], ["mean"])
>>> c[0]["observed"], c[0]["p_value"]

(2.0, 0.5)