Skip to content

Executable examples

Thirteen small scripts exercise the main workflow families. They are intentionally compact enough to read in one sitting and concrete enough to run as smoke tests.

Mediation

Multilevel gaze mediation contract

Simulate repeated trials, prepare within/between components, specify the Bayesian model, and inspect estimable paths without requiring a sampler run.

python examples/multilevel_gaze_mediation_contract.py View source →
Guardrails

Mediation failure cases

Exercise missingness, non-estimable paths, unsupported random slopes, and family-support errors explicitly.

python examples/multilevel_gaze_mediation_failure_cases.py View source →
Sensitivity

Multilevel mediation prior sensitivity

Keep the mediation data/model contract fixed while declaring narrower, default, and wider coefficient-prior scales.

python examples/multilevel_gaze_mediation_prior_sensitivity_contract.py View source →
Likelihoods

Multilevel mediation family contracts

Validate lognormal, Gamma, beta, Bernoulli, Poisson, and negative-binomial mediator support without sampling.

python examples/multilevel_gaze_mediation_family_contracts.py View source →
Validation

Simulation/recovery planning

Generate weak, moderate, and strong known-truth mediation scenarios and verify the same preparation/model contract before backend-enabled recovery studies.

python examples/multilevel_gaze_mediation_simulation_recovery_contract.py View source →
Foundation

Binary workflow

Simulation → preparation → specification → prior predictive checking.

python examples/binary_workflow.py View source →
Foundation

Duration workflow

Positive-duration simulation and lognormal workflow specification.

python examples/duration_workflow.py View source →
Diagnostics

Predictive diagnostics

Backend-free ROC, precision-recall, and calibration diagnostics.

python examples/predictive_diagnostics.py View source →
Model comparison

PSIS-LOO comparison

Pointwise log-likelihood draws, Pareto-k diagnostics, and descriptive ELPD comparison.

python examples/loo_model_comparison.py View source →
Sensitivity

Sensitivity workflow

Declarative sensitivity planning with automatic model selection and exclusion disabled.

python examples/sensitivity_workflow.py View source →
Reproducibility

Analysis manifest

Capture deterministic fingerprints for data, contract, specification, and transformations.

python examples/reproducibility_workflow.py View source →
Pupillometry

Pupil workflow

Advanced simulation, governed analytic fitting, trajectory prediction, and temporal audit.

python examples/pupil_workflow.py View source →
Environment

Backend status

Inspect optional backend capability and environment state without compilation.

python examples/backend_status.py View source →

Run from a source checkout

PYTHONPATH=src python examples/predictive_diagnostics.py

After installation, ordinary python is sufficient because gp3bayespy is importable from the active environment.

Suggested order

  1. multilevel_gaze_mediation_contract.py
  2. multilevel_gaze_mediation_failure_cases.py
  3. multilevel_gaze_mediation_prior_sensitivity_contract.py
  4. multilevel_gaze_mediation_family_contracts.py
  5. multilevel_gaze_mediation_simulation_recovery_contract.py
  6. binary_workflow.py
  7. predictive_diagnostics.py
  8. loo_model_comparison.py
  9. sensitivity_workflow.py
  10. reproducibility_workflow.py
  11. pupil_workflow.py

For a guided narrative rather than scripts, continue to the Article library.