Prior Predictive Checks

Run prior predictive checks before fitting when you want to test whether your configured priors imply plausible target behaviour.

If you want the econometrics framing for this workflow, see Prior Predictive Checks for Econometricians.

Sample prior predictive draws

Use sample_prior_predictive(...) on PanelMMM:

prior = mmm.sample_prior_predictive(
    X=X,
    y=y,
    samples=100,
    random_seed=42,
)

In normal PanelMMM use, pass the same X and y structure that you plan to fit.

sample_prior_predictive(...):

  • builds the model if it has not been built yet
  • samples from pymc.sample_prior_predictive(...)
  • stores prior and prior_predictive on mmm.idata by default
  • returns an extracted xarray.Dataset of prior predictive draws

How many draws Abacus uses

If you do not pass samples=..., Abacus uses:

  • sampler_config["draws"] when that key exists
  • otherwise 500

If you want prior predictive checks to use a different sample count from model fitting, pass samples explicitly.

Plot prior predictive draws

After sampling, you can use the retained plotting surface:

figure, axes = mmm.plot.prior_predictive(
    var=mmm.output_var,
    hdi_prob=0.85,
)

You can then access the stored groups directly:

prior_group = mmm.prior
prior_predictive_group = mmm.prior_predictive

Trying to access these groups before sampling raises a runtime error.

Example prior predictive output:

Prior predictive example Prior predictive example

What to inspect

A useful prior predictive check is about plausibility, not fit.

Check:

  • scale: are draws on roughly the same order of magnitude as the observed target?
  • support: do the draws violate obvious business constraints such as non-negativity?
  • volatility: do the draws imply far more or far less variation than the real series?
  • structure: do the trajectories look broadly plausible for the business and model configuration?

If the prior predictive distribution is implausible, change the model before you fit it.

Adjust the model before fitting

Typical changes include:

  • tightening intercept or likelihood priors in model_config
  • revising media transformation priors
  • reducing unnecessary model flexibility
  • checking whether your scaling choices make priors too loose on the model scale

See Priors and Configuration for the configuration surface.

Prior predictive before and after fit

If you run prior predictive checks first and then call fit(), Abacus keeps the existing prior and prior_predictive groups on mmm.idata.

That makes it practical to compare:

  • prior assumptions
  • posterior fit
  • posterior predictive behaviour

within one saved InferenceData object.

Common pitfalls

  • Skipping prior predictive checks and only noticing implausible priors after a long fit
  • Treating prior predictive checks as a substitute for posterior predictive assessment
  • Forgetting that sample_prior_predictive(...) returns extracted predictive draws, while the full prior and prior_predictive groups are stored on mmm.idata

Next steps

After the prior predictive behaviour looks reasonable, fit the model with Fitting the Model.