Posterior Predictive Checks

Contents

Posterior Predictive Checks#

lightning.ppc.ppc(lgh, samples, logprob_samples, Nrep=1000, seed=None, counts_dist='gaussian')#

Compute the posterior predictive check p-value given a set of samples and a Lightning object

Parameters:
lghlightning.Lightning object

Used to compute chi2 values.

samplesnp.ndarray, (Nsamples, Nparam), float

The samples to compute the PPC with. Note that this must also include any constant parameters, since we need them to compute the model luminosities.

logprob_samplesnp.ndarray, (Nsamples,), float

The logprob corresponding to each sample. Used to weight samples.

Nrepint

Number of realizations of the data to compute from the model.

seedfloat

Seed for random number generation.

Returns:
p-valuefloat

A single p-value for the given chain. Extremely low p-values indicate underfitting, that the model is not flexible enough to produce the observed variation in the data (or that the uncertainties on the data are too small), while extremely high p-values (close to 1) may indicate over-fitting, where the model is too flexible (or the uncertainties overly conservative).

Notes

The implementation of PPC here is ported from IDL Lightning.

lightning.ppc.ppc_sed(lgh, samples, logprob_samples, Nrep=1000, seed=None, ax=None, normalize=False, counts_dist='gaussian')#

Make an SED plot representing the posterior predictive check.

The idea is that this can serve as a diagnostic plot showing where the model may be too inflexible to reproduce individual datapoints. This may show you if, e.g. your low p-value is driven by an individual band.

Parameters:
lghlightning.Lightning object

Used to compute chi2 values.

samplesnp.ndarray, (Nsamples, Nparam), float

The samples to compute the PPC with. Note that this must also include any constant parameters, since we need them to compute the model luminosities.

logprob_samplesnp.ndarray, (Nsamples,), float

The logprob corresponding to each sample. Used to weight samples.

Nrepint

Number of realizations of the data to compute from the model.

seedfloat

Seed for random number generation. Useful for matching your PPC p-value to the plot.

axmatplotlib.axis.Axes

Axes to draw the plot into.

normalizebool

If True, the data and quantiles of the reproduced data are divided by the median of the reproduced data before plotting.

Returns:
PPC SED plot figure: an SED plot showing the quantile bands of the reproduced
data, with the observed data overplotted.