Skip to content

About

Interactive Bayesian statistics tools — Prior Lab, MCMC, brms Builder, DAG/Causal, Decision Lab

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Latest commit

 

History

730 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Bayes Thinking Lab v0.9 beta

Statistical Intuition, Reimagined.

License: MIT Static Badge Static Badge

27 interactive tools that guide users from frequentist foundations through Bayesian multi-level modeling to principled posterior decision-making — including a guided introduction to causal reasoning with DAGs (Causal Terror), causal effect estimation via G-Computation, parametric data generation, and GLM-scale prior specification. Available in German and English.

[ Learning Path ] • [ Ecosystem ] • [ Philosophy ] • [ Usage ] • [ GitHub Repository ]


🔭 Scientific Philosophy

The Bayes Thinking Lab (BTL) moves away from the "black-box" approach of statistical software. Inspired by the pedagogical works of John Kruschke and Richard McElreath, this project emphasizes:

  • Visual Proofs: Concepts like Partial Pooling, Link Functions, and HDI vs. ROPE become tangible through real-time manipulation.
  • The Formula-Graphic Duality: Hierarchical models are simultaneously represented as Kruschke-style diagrams and in mathematical notation consistent with McElreath and brms.
  • Workflow Integration: Beyond interactive demos, the lab functions as a productivity tool — generating production-ready brms code for R and supporting the full Bayesian workflow from prior specification to posterior decision.

🗺 The Learning Path

The lab is organized into six sections that build on each other. Work through them in order, or jump in wherever your current knowledge begins.

Section What you will learn Key Tools
0 · Foundations Why the GLM is the gateway to Bayesian thinking Interactive LM · MLE Tool · LM→GLM Transition
I · GLM & GLMM How regression generalizes across distributions and hierarchies Distribution Lab · GLM Conditional Distributions · GLM 3D · Interactive GLMM
II · Bayesian Intuition How to think in probability distributions and update beliefs from data Why Bayes? · Thinking Simulator · Likelihood Compass · Prior Compass · Prior Lab · MCMC Visualizer · Bayes Interactive
III · Small Worlds How to construct models: understand causal structure, sketch it as a DAG, simulate data, plan power Causal Terror · Golem Builder · Data Creator
IV · Bayesian Workflow How to specify, build, check, compare, and export hierarchical Bayesian models Model Architect · brms Builder · Advanced Model Builder · Prior & Posterior PC · LOO Lab
V · Posterior Decision How to make principled, transparent decisions from posterior distributions Causal Calculator · G-Comp Builder · Decision Lab · Decision Maker

⬡ Workflow tip: New to DAGs? Start with Causal Terror (Section III — Small Worlds). Then use the Golem Builder to do the causal groundwork: draw your DAG, identify confounders, and determine the correct adjustment set. Transfer everything to the G-Comp Builder (Section V) at the click of a button — it generates ready-to-run marginaleffects R code for ATE, ATT, and ATU, and exports MCMC draws directly to the Decision Maker.


🛠 The Ecosystem

0. Statistical Foundations

Master the GLM — the prerequisite for Bayesian thinking.

  • Interactive LM — Manipulate data points and watch OLS minimization and residuals update in real time. Build intuition for what a regression line actually optimizes.
  • Maximum Likelihood — Explore the conceptual distinction between probability and likelihood by adjusting parameters interactively against simulated data.

  • LM → GLM Transition — Discover why link functions are necessary for non-normal outcomes and how the GLM generalizes the linear model across distribution families.

I. From LM to GLMM

Scale the hierarchy of linear modeling.

  • Distribution Lab — Explore 31 probability distributions interactively — adjust parameters, show moments, and read off brms parameterisation and link functions directly. Covers all major GLM and Bayesian likelihood families: Normal, Student-t, Cauchy, Skew-Normal, Log-Normal, Gamma, Weibull, Beta, Bernoulli, Poisson, Negative Binomial, ZI-Beta, ZOIB, Beta-Binomial, zero-inflated and hurdle families, ordinal (cumulative) models, the LKJ prior, and more. A built-in cheat sheet and a relationships diagram show how the distributions connect. Ideal preparation before fitting GLMs or specifying priors in brms.

  • GLM Conditional Distributions — Visualize the conditional distribution y|x along a predictor across 8 model families: Normal, Student-t, Bernoulli (logistic), Poisson, Gamma, Ordinal (cumulative logit), Zero-Inflated Poisson, and Hurdle-Poisson. Compare parameter behavior and link functions across families.

  • GLM in 3D — Interact with regression planes and residuals in a spatial environment. Explore how multiple predictors jointly determine the outcome surface.

  • Interactive GLMM — Simulate grouped data and compare Complete Pooling, No Pooling, and Partial Pooling side by side. Observe Simpson's Paradox, the Intraclass Correlation Coefficient (ICC), and the shrinkage mechanism — for Normal, Poisson, Gamma, and logistic outcomes.


II. Bayesian Intuition

Learn to think in probability distributions.

  • Why Bayes? — What can a Bayesian posterior tell you that a p-value can't? A two-act comparison: frequentist output first, then an interactive posterior with a movable effect threshold and a live prior-update — no R required. Makes concrete why a credible interval is not a confidence interval.
  • Bayesian Thinking Simulator — Work through 8 psychological scenarios that build qualitative updating intuition without requiring mathematical notation.
  • Likelihood Compass — Before the first prior is set, a different decision has to be made: which distribution family actually fits the data-generating process — not just the histogram. A guided decision tree leads from reaction times, sum scores, and count data to a reasoned shortlist. Check candidates against your own dataset via Maximum Likelihood (AIC/BIC), then jump straight to the brms reference: required parameters, priors, and go-to defaults per family.
  • Prior Compass — Why do you need a prior at all, for which model parameter, and in which value range? A parameter atlas, a GLM link-scale explainer, and a decision wizard that leads to a concrete prior suggestion with a deep link into the Prior Lab.
  • Prior Lab — Translate verbal uncertainty statements into mathematical priors across 12 distributions. A real-time CI-solver maps your beliefs onto distribution parameters. GLM Mode: enter your bounds as probabilities (logit-link) or expected values (log-link) — the solver converts to model scale automatically, and a dual-panel plot shows both the prior as brms needs it and what it implies on the response scale (probabilities, Odds Ratios, Rate Ratios) — via a mathematically exact Jacobian transformation (change-of-variables theorem), not an approximation.

  • MCMC Visualizer — Watch the Metropolis-Hastings sampler navigate the posterior landscape — the "animated hiker" analogy made interactive.

  • Bayes Interactive — Manipulate prior strength, likelihood, and sample size and see how they jointly shape the posterior. Includes CI and PPI bands for the full posterior predictive.

III. Small Worlds

Named after Richard McElreath (Statistical Rethinking, Ch. 2): a model is a "small world" — a simplified, consistent representation of reality. Before real data are collected or models fitted, it is worth explicitly constructing and simulating this small world.

  • Causal Terror — Learn what adjusting for a variable does to the effect you want to estimate — no prior knowledge of causal inference needed. Named after McElreath's chapter on the haunted DAG and the causal terror (Statistical Rethinking, Ch. 6). Three stages: (1) information flow in the three basic structures confounder (fork), mediator (chain), and collider; (2) reading paths in example graphs (M-bias, collider descendants, front-door, instrument) or in a DAG you build yourself, with live feedback on which path opens or closes where; (3) application to sport → heart health: choose adjustment sets for the total effect and the direct effect, see the consequence of every click, and derive the indirect effect — followed by a formal derivation with the three rules of the do-calculus.

  • Golem Builder — Draw directed acyclic graphs (DAGs), compute d-separation and testable implications (compatible with dagitty), identify minimal adjustment sets, detect instrumental variables and the Front Door criterion. Quantify relationships, simulate data directly from the DAG, and export production-ready brms and glmmTMB analysis code — all in the browser. Exactly following McElreath's approach. One-click export to the G-Comp Builder transfers exposure, outcome, adjustment set, and formula automatically — no R code required.

  • Data Creator — Parametric data generation for all common designs: between-subjects, within-subjects (repeated measures), and mixed designs — with covariates, cluster structures (random intercepts & slopes), and arbitrary sample sizes. Covariates have a slope on the outcome — optionally per group, which creates a factor × covariate interaction — and are centered at their grand mean. Supports 9 likelihood families (Gaussian, Student-t, Log-Normal, Gamma, Bernoulli, Beta, Binomial, Poisson, Negative Binomial). Full faux and glmmTMB R code export, plus a commented simulation-based power analysis block (glmmTMB + car::Anova) — ready to run in R.

⬡ Workflow tip: Do the causal groundwork first — learn the logic in Causal Terror, then draw your DAG in the Golem Builder and identify which variables to adjust for. Transfer everything to the G-Comp Builder at the click of a button to generate ready-to-run R code for G-Computation, then export MCMC draws to the Decision Maker.


IV. Bayesian Workflow

Tools for the applied scientist.

  • Bayesian Model Architect — Build hierarchical Bayesian model structures visually in Kruschke-diagram style. See how priors, hyperpriors, and random effects (intercepts and slopes: u₀ⱼ, u₁ⱼ, τ₀, τ₁) connect in a live diagram — then generate R simulation code for prior predictive checking.
  • brms Model Builder — Specify complex hierarchical models step by step across 15+ likelihood families, polynomial terms, interactions, and distributional parameters. Export production-ready brms code for R. The generated code includes a commented-out posterior_predict() export block — ready to load into the Posterior Predictive Check app.
  • Advanced Model Builder — Companion to the brms Model Builder for rare/advanced building blocks it doesn't cover: multivariate models, random-effects correlation structures (||, |ID|), splines, monotonic effects, measurement-error models, and missing-data handling.
  • Prior Predictive Check — Import your brms model specification, explore the prior predictive distribution, and validate that your priors generate plausible data before fitting.
  • Posterior Predictive Check — Evaluate model fit and posterior behavior via a dedicated Shiny app (R/bayesplot). Upload a saved brms object (saveRDS(fit, "model.rds")), walk through KDE overlay, summary statistics, error structure, and prediction intervals with guided evaluation.
  • LOO Lab — Compare models after fitting. Paste loo_compare() output directly from R and receive an annotated forest plot, Pareto-k diagnostics, and a traffic-light decision rule. Includes an animated LOO walkthrough (Stage 1) that requires no R.

V. Posterior Decision

Move from estimation to decision.

  • Decision Lab — Apply three principled decision frameworks to any posterior distribution: Kruschke's HDI vs. ROPE trichotomy (accept / reject / undecided), Full ROPE % (probability of practical equivalence), and ETI vs. ROPE. Supports Normal, Student-t, and Gamma posteriors with analytically correct HDI and ETI computation.
  • Decision Maker — Upload your own posterior samples via CSV (from brms, Stan, or rstanarm), define transformations and derived quantities as formulas (Cohen's d, Odds Ratios, etc.), compute HDI and ETI, and export a complete APA-formatted decision report — ready to paste into a manuscript.
  • Causal Calculator — A worked example of causal effect estimation via G-Computation (standardization). Shows how to make confounding visible, correct naive regression bias, and compare ATE, ATT, and ATU — visualized as counterfactual distributions. Ideal entry point into G-Computation; for your own analyses use the G-Comp Builder.
  • G-Comp Builder — Generates ready-to-run R code for G-Computation via marginaleffects: ATE, ATT, and ATU for binary exposures; AME and dose-response curve for metric exposures. Import DAG structure, exposure, outcome, and adjustment set directly from the Golem Builder at the click of a button. Generates CSV export code for MCMC draws compatible with the Decision Maker — completing the causal inference workflow entirely in the browser.

📚 Reference & Study Aids

Alongside the tools, the lab ships three supporting pages: a glossary of almost 500 statistical terms (linked from within the tools, with hover definitions), flashcards for self-testing the glossary, and a reference list of the literature behind the tools.


🚀 Getting Started

The Bayes Thinking Lab is a serverless web application. No installation, no backend, and no data leaves your machine. All tools are available in German (index_de.html) and English (index.html, tools in en/).

Option 1 — Use it online (recommended)

Open the hosted version directly in your browser:

🌐 www.bayes-thinking-lab.uni-osnabrueck.de

No setup required.

Option 2 — Run it locally

  1. Clone the repository:
    git clone https://github.com/raduesing/Bayes_Thinking_Lab.git
  2. Open index.html in any modern web browser.
  3. Follow the learning path — or jump directly to the tool that matches your current need.

Tip: Each tool includes a built-in ℹ Help panel and inline explanations for every parameter. Use the Guide in Model Architect and brms Builder for step-by-step walkthroughs.


🎓 Target Audience

Level Recommended Entry Point Tools to Explore
BSc Students Section 0 — Foundations Interactive LM · MLE Tool · Thinking Simulator · Distribution Lab · Prior Compass · Prior Lab (CI-Solver) · Bayes Interactive · Causal Terror
MSc Students Section I–II GLM Conditional Distributions · Interactive GLMM · Likelihood Compass · Prior Lab (GLM Mode) · Causal Terror · Model Architect · Decision Lab
PhD / Researchers Section III–V Golem Builder · Data Creator · brms Model Builder · Prior & Posterior PC · LOO Lab · Causal Calculator · G-Comp Builder · Decision Maker

🛠 Built With

Vanilla JS · D3.js · No framework · No build step · Runs entirely in the browser.


🖋 Scientific Acknowledgments

The development of the Bayes Thinking Lab is grounded in the pedagogical and methodological frameworks established by the following researchers:

Author Framework / Contribution Resource
John K. Kruschke Graphical model representations follow the Kruschke Diagram conventions from Doing Bayesian Data Analysis. Blog
Richard McElreath Model notation, workflow structure, and prior predictive thinking are informed by Statistical Rethinking (Ch. 5–6, 14). GitHub
A. Solomon Kurz Acknowledgment to his brms and tidyverse translations of Kruschke and McElreath, which informed several implementation details. Website
Paul-Christian Bürkner All exported code targets the brms R package. Prior notation (class=sd, τ₀, τ₁) follows brms conventions. brms

Note on Licensing: This project is released under the MIT License. All external references and conceptual frameworks belong to their respective copyright holders.


🎓 Citation

If you use the Bayes Thinking Lab for research, teaching, or software development, please cite it as follows:

APA Style

Düsing, R. (2026). Bayes Thinking Lab: An interactive suite for Bayesian intuition and brms workflow (Version 0.9 beta). GitHub. https://github.com/raduesing/Bayes_Thinking_Lab

BibTeX

@software{Duesing_Bayes_Thinking_Lab_2026,
  author  = {Düsing, Rainer},
  title   = {{Bayes Thinking Lab: An interactive suite for Bayesian intuition and brms workflow}},
  url     = {https://github.com/raduesing/Bayes_Thinking_Lab},
  version = {0.9.0},
  year    = {2026}
}

📬 Contact

Bayes Thinking Lab · University of Osnabrück
✉️ www-b-t-l@uni-osnabrueck.de

About

Interactive Bayesian statistics tools — Prior Lab, MCMC, brms Builder, DAG/Causal, Decision Lab

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages