calpit.diagnostics
Local diagnostics of conditional density estimates (Zhao et al. 2021).
For a well calibrated CDE at x, the PIT is uniform, so r(alpha; x) = P(PIT <= alpha | x) equals alpha: the local P-P plot is the diagonal. How far the predicted r strays from the diagonal measures the miscalibration at x.
Attributes
Classes
Predicted local P-P curves of a set of CDEs. |
Functions
|
Plots the local P-P curves of some objects against the diagonal. |
Module Contents
- class LocalCalibration[source]
Predicted local P-P curves of a set of CDEs.
- Variables:
alpha – The coverage levels, increasing, shape (n_alpha,).
pit_cdf – The predicted r(alpha; x) of each object, shape (n_objects, n_alpha).
- alpha: FloatArray[source]
- pit_cdf: FloatArray[source]
- property ks: FloatArray[source]
The largest distance of each local P-P curve from the diagonal, shape (n_objects,).
- property cvm: FloatArray[source]
The root mean squared distance from the diagonal over alpha, shape (n_objects,).
- coverage(level: float) FloatArray[source]
Returns the coverage of the central interval at a nominal level.
- Parameters:
level – The nominal coverage of the interval between the (1 - level) / 2 and (1 + level) / 2 quantiles, in (0, 1).
- Returns:
The predicted probability that the true value falls in that interval, for each object, shape (n_objects,).
- _pit_cdf_at(alpha: float) FloatArray[source]
Interpolates every local P-P curve linearly at one alpha.
- plot_local_pp(diagnostics: LocalCalibration, indices: numpy.typing.ArrayLike, ax: Any = None) tuple[Any, Any][source]
Plots the local P-P curves of some objects against the diagonal.
- Parameters:
diagnostics – The local P-P curves.
indices – The objects to plot.
ax – The matplotlib Axes to draw on, or None to create a figure.
- Returns:
The figure and the axes, as a tuple (fig, ax).
- Raises:
ImportError – If matplotlib is not installed.