Skip to content

Worked examples

These pages turn the former Quarto notebooks into a guided tour of model authoring with StanBlocks. Runnable examples are evaluated during the documentation build: the Julia source shown on a page is the exact source that produced the complete Stan program shown with it.

How to read the executable examples

Every generated example uses the same presentation as the feature atlas: 2. read the model in the StanBlocks tab;

  1. switch to Generated Stan to inspect the complete emitted program; or

  2. choose Compare side by side for a wide modal with both versions.

Family pages evaluate one source block and label every resulting Stan program. Nothing asks the reader to run Julia in order to see the output. The prose before each block explains the statistical progression and calls out the DSL features that make it possible.

Model families

  • Golf models progresses from logistic regression to geometry-based putting models, residual variation, and estimated physical tolerances. It highlights Base.merge, inferred declarations, and ordinary Julia preprocessing.

  • PCR sensitivity versus time builds a 5×2 family from five latent-time structures and two link functions. It highlights @deffun, higher-order dispatch, varargs, custom likelihoods, and recursive model-family construction.

  • Crowdsourced ratings builds a latent-truth/rater model and 18 restrictions of it. It highlights custom likelihood families, generated checks, and post-hoc component replacement.

  • Reusable constraints covers a disk transform and ten simplex transforms. It highlights named-tuple returns, function-valued arguments, custom parameter-introducing distributions, and Jacobian terms.

Case studies

  • Golf putting — composition through reusable probability submodels.

  • Motorcycle data — a Hilbert-space GP component reused for both the mean and log scale.

  • Multilevel radon regression — complete, no, and partial pooling plus the CV marker.

  • Planetary motion — the original forward simulator, k-only inverse problem, and full unknown-star ODE model.

  • Disease transmission — an SIR system with prevalence, incidence, and under-reported-incidence observation models.

  • Multiple species-site occupancy — the original discrete-state-marginalized occupancy likelihood and generated abundance quantities.

  • Soil carbon — a two-pool feedback ODE reused by direct-residual and latent measurement-error observation models.

  • Monster pharmacokinetics — a four-compartment PBPK model expressed both directly in StanBlocks and through BRM's named subject-level formula predictors and group-local kernel.

Maintained implementation references

  • PosteriorDB implementations inventories the 77 current optional-extension models and explains how the catalogue is organized without duplicating its maintained source file.

Design and historical material

These historical pages are curated records rather than raw dumps: each says what the experiment was trying to demonstrate, which parts correspond to current StanBlocks features, and where the original exploration intentionally stopped.

You are viewing the dev branch. This branch may include code written with Claude Code with less human supervision. Only human-approved code is merged into main.