Bayesian Regression β€” Interactive

Prior Β· Likelihood Β· Posterior Β· Kruschke Diagram Β· Prior Predictive Β· MCMC Sampler

Β© Dr. Rainer DΓΌsing Β· Interactive Tools by Claude

πŸŽ“ Sleep Duration β†’ Perceived Stress (PSS, z-score) Β· Step 1 of 7
β‘  β‘‘ β‘’ β‘£ β‘€ β‘₯ ⑦
MODEL STRUCTURE
Kruschke Diagram
Arrows = stochastic dependence ↓  Β·  β–  Hyperpriors   β–  Priors   β–  Likelihood   β–  Data
PRIOR PREDICTIVE CHECK
What does the model say before the data? (McElreath approach)
60 Prior Lines
Each line = Ξ±~N(ΞΌ_Ξ±,Οƒ_Ξ±), Ξ²~N(ΞΌ_Ξ²,Οƒ_Ξ²).
Large Οƒ_Ξ± or Οƒ_Ξ² β†’ many plausible worlds.
PRIOR β†’ POSTERIOR UPDATE
How the data update the prior
Prior Pred. Post. Pred. Post. Median True Line
Intercept Ξ± Prior Post.
β€”
Slope Ξ² Prior Post.
β€”
Residual SD Οƒ Prior Post.
β€”
P(θ|y) ∝ P(y|θ)·P(θ)
Narrow posterior curve = more certainty.
Prior curve shifts with a tight prior.
MCMC β€” METROPOLIS-HASTINGS
How the sampler explores the posterior space
Heatmap = log P(Ξ²,Οƒ|y)  Β·  ● accept.   ● reject.   βœ• true   ● current
Iter: 0 Acceptance: β€” Speed:15/s
Trace Plot Ξ²  β€” true
Histogram Ξ²  (post burn-in)
Trace Plot Οƒ  β€” true
Histogram Οƒ  (post burn-in)
Metropolis Step:
1. Propose Ξ²*~N(Ξ²,0.15Β²), log Οƒ*~N(log Οƒ,0.12Β²)
2. r = P(Ξ²*,Οƒ*|y) / P(Ξ²,Οƒ|y)
3. Accept if U(0,1) < min(1,r)
πŸŽ“ Tutorial β€” Bayesian Regression
The Example
You are analysing data from n = 30 psychology students. Predictor x: average sleep duration (z-scored). Outcome y: perceived stress (PSS β€” Perceived Stress Scale, Cohen et al. 1983, z-scored).

Hypothesis: more sleep β†’ less stress (Ξ² < 0). The true effect is Ξ² = βˆ’0.8.
What you will learn
In 7 guided steps you experience the complete Bayes cycle:

β‘  Setup β€” configure parameters, explore the dataset
β‘‘ Prior Predictive Check β€” plausible slopes a priori
β‘’ Prior β†’ Posterior Update β€” Bayesian learning
β‘£ Effect of sample size n
β‘€ Outlier influence under Normal likelihood
β‘₯ Robustness via Student-t likelihood
⑦ MCMC sampler β€” joint posterior Ξ² Γ— Οƒ
How it works
Each step tells you what to do and what to observe. The active panel is outlined in colour and the relevant step card is shown bottom-right.

Use βš™ Apply Values to automatically set all sliders to the recommended values. You can also explore freely β€” the tutorial only provides guidance.
The Steps panel appears as a green box in the bottom-right corner β€” always visible, no scrolling needed.
β„Ή Bayesian Regression β€” Help
What will I learn here?
The complete Bayes cycle for linear regression: Prior β†’ Likelihood β†’ Posterior. You control the true parameters and the prior assumptions β€” and immediately see how both shape the posterior.
The Model
Ξ± ~ N(ΞΌ_Ξ±, Οƒ_Ξ±) Β· Ξ² ~ N(ΞΌ_Ξ², Οƒ_Ξ²) Β· Οƒ ~ HalfNormal(s_Οƒ)
y ~ N(Ξ± + Ξ²Β·x, Οƒ) β€” the likelihood

Left sidebar: true parameters (simulate the data) Β· priors (your assumptions about Ξ±, Ξ², Οƒ)
The Five Panels
CI vs. Prediction Interval
95% CI Mean (green, narrow): Uncertainty about the location of the regression line β€” contains only parameter uncertainty.

95% PPI New Observation (dashed, wider): where will a new data point fall? Also includes residual scatter Οƒ.

With small Οƒ the CI and PPI are close β€” with large Οƒ the PPI is much wider.
Gaussian vs. Outlier-robust
Gaussian: y ~ N(Ξ± + Ξ²Β·x, Οƒ) β€” standard
Outliers: y ~ t(Ξ½, Ξ± + Ξ²Β·x, Οƒ) β€” heavier tails, more robust against individual extreme values
Next β†’ Bayesian PP Check: Posterior Predictive Checks for model diagnostics