English

Phantom types for robust hierarchical models with typegeist

Computation 2025-10-31 v1

Abstract

In Bayesian hierarchical models, group-level parameter arrays must be mapped to the observation axis, often using explicit indexing. In complex models with numerous incompatible data and parameter sets, this introduces the potential for bugs, as indexing with the incorrect indices typically fails silently. Here we present typegeist, a type system for Python that uses static type analysis to enable specification and enforcement of data-parameter-index correspondences. We show how this can be used with common probabilistic programming frameworks to help guarantee model correctness with minimal run-time overhead.

Cite

@article{arxiv.2510.26726,
  title  = {Phantom types for robust hierarchical models with typegeist},
  author = {Daniel O'Hanlon},
  journal= {arXiv preprint arXiv:2510.26726},
  year   = {2025}
}
R2 v1 2026-07-01T07:14:15.135Z