pymc-devs / pymc-devs/pymc-examples
New example notebook: Topological posterior predictive checks
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 398
- Forks
- 325
- Avg merge
- 9d 15m
- Merged PRs (30d)
- 1
Description
Notebook proposal
New example notebook: Topological posterior predictive checks:
Why should this notebook be added to pymc-examples?
I would like to add a new example notebook showing how persistent-homology summaries can be used as posterior predictive discrepancy statistics in PyMC workflows.
The notebook compares two models on a synthetic seasonal time series:
- A misspecified Gaussian model fitted to a delay-coordinate embedding of the time series.
- A Fourier seasonal model fitted to the original time series.
The main thesis is that ordinary posterior predictive checks can pass when low-order summaries such as means and covariances are reproduced, while still missing global shape. In the example, the Gaussian embedding model matches low-order summaries but fails to reproduce the recurrent loop structure of the delay embedding. This failure is detected by topological summaries such as maximum H1 persistence and Betti-1 posterior predictive envelopes.
After revising the model to include seasonal Fourier terms, the posterior predictive delay embeddings better reproduce the observed recurrent topology. The notebook therefore illustrates a Bayesian workflow pattern:
ordinary PPC passes
→ topological PPC detects missing global structure
→ model is revised
→ posterior predictive topology improves
Suggested categories:
- Level: Intermediate / advanced
- Diataxis type: How-to guide, with a case-study style example
Related notebooks
This notebook would build on the existing PyMC examples around posterior predictive checks and model criticism, but it would cover a different diagnostic target.
Related existing examples include:
- Prior and Posterior Predictive Checks — this is the closest conceptual predecessor, since the proposed notebook also focuses on posterior predictive model criticism.
- Model Comparison and other diagnostics/model-criticism examples — these cover comparison and evaluation of fitted models, whereas this notebook focuses on checking whether posterior predictive samples reproduce global geometric/topological structure.
- Time-series examples such as interrupted time-series analysis — the proposed notebook uses a synthetic seasonal time series, but the focus is not time-series forecasting itself. The focus is using delay embeddings and persistent homology as posterior predictive discrepancy statistics.
I think this should be a new notebook rather than an extension of an existing one because the main idea is distinct: it introduces topological summaries of posterior predictive samples as a model-checking tool. Adding this to a general posterior predictive checks notebook would make that notebook too long and would require introducing persistent homology, delay embeddings, and Betti/persistence diagnostics in the middle of a broader tutorial.
The proposed notebook is intended to be self-contained and relatively short: it introduces the synthetic data, fits the two PyMC models, computes ordinary and topological posterior predictive checks, and explains how the topological failure guides model revision.
References
- Gelman, A., Carlin, J. B., Stern, H. S., Dunson, D. B., Vehtari, A., and Rubin, D. B. (2013). Bayesian Data Analysis (3rd ed.). Chapman and Hall/CRC. See especially the discussion of posterior predictive checks and Bayesian model criticism.
- Edelsbrunner, H., and Harer, J. (2010). Computational Topology: An Introduction. American Mathematical Society. ISBN: 978-0-8218-4925-5.
- Ghrist, R. (2008). “Barcodes: The persistent topology of data.” Bulletin of the American Mathematical Society, 45(1), 61–75. doi:10.1090/S0273-0979-07-01191-3.
- Thorne, T., Kirk, P. D. W., and Harrington, H. A. (2022). “Topological approximate Bayesian computation for parameter inference of an angiogenesis model.” Bioinformatics, 38(9), 2529–2535.
This notebook is related to work using topological summaries for likelihood-free and approximate Bayesian computation. Its focus is different: it uses persistent-homology summaries as posterior predictive discrepancy statistics for model criticism in a standard PyMC workflow.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the existing Prior and Posterior Predictive Checks and time-series examples for structure and conventions. Create a self-contained notebook with synthetic seasonal data, the two proposed PyMC models, ordinary and topological posterior predictive checks, and the model revision. Done means the notebook clearly shows topology detecting the misspecification and improving after revision.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- jupyter-notebook, python
- Domain
- documentation, machine-learning
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100