(G)LMM — Mixed Models Interactive

Gaussian · Poisson · Gamma · Logistic · Partial/No/Complete Pooling · Shrinkage · ICC · Simpson

© Dr. Rainer Düsing · Interactive Tools by Claude

⚠ Illustration tool: Estimates via IRLS + Method-of-Moments — no Laplace approximation (lme4/glmmTMB). Direction and order of magnitude are correct, exact values may differ.

LIKELIHOOD:
POOLING:
MAIN PLOT — DATA & REGRESSION LINES
Partial Pooling: Group lines with shrinkage
Simpson risk: Complete pooling line shows a different direction than the within-group effects — do not ignore the group structure!
SHRINKAGE DIAGRAM
No Pooling vs. Partial Pooling Intercepts
How to read? Each row = one group, sorted by no-pooling intercept (top = largest). ○ = No-Pooling  ·  ● = Partial-Pooling. Arrow shows direction and strength of shrinkage toward the grand mean (γ̂₀₀, dashed).
MODEL RESULTS
Estimated Parameters & Metrics
What is a Mixed Model?
A Mixed Model combines Fixed Effects (γ — the same for all groups) with Random Effects (u₀ⱼ — group-specific deviations). The basic model is:

y_ij = γ₀₀ + γ₁₀·x_ij + u₀ⱼ + ε_ij

The u₀ⱼ are not estimated directly but modeled as random variables: u₀ⱼ ~ Normal(0, τ₀²). This enables information sharing between groups — each group benefits from the data of the others.
Complete · No · Partial Pooling
Complete Pooling: One line for all — group structure is ignored. Efficient, but biased when groups truly differ.

No Pooling: Independent lines per group. No information sharing — overfitting with small n_j.

Partial Pooling (Mixed Model): The golden middle ground. Group-specific estimates are pulled toward the grand mean (Shrinkage). Groups with little data are pulled more strongly — the model "trusts" them less.
ICC — Intraclass Correlation
ICC = τ₀² / (τ₀² + σ²)

The proportion of total variance that lies between groups. Rule of thumb: ICC > 0.05 → LMM is necessary, since observations within a group are not independent.

Shrinkage factor λ = τ₀² / (τ₀² + σ²/n_j)

Determines how strongly the group-specific estimate is pulled toward the grand mean. With small n_j or small τ₀ → strong shrinkage. Visible in the shrinkage diagram as arrow length.
Simpson's Paradox
When x correlates with group membership (x-group offset > 0), the marginal trend (complete pooling over all data) can be opposite to the within-group trend.

Example: Within each group y increases with x — but groups with high x also have lower intercepts. The complete pooling line shows a negative overall trend, even though the true effect is positive.

Solution: Partial pooling separates the within-group effect (γ₁₀) from the between-group effect.
Random Intercept vs. Intercept + Slope
Random Intercept (τ₀ > 0): Groups differ in their baseline level — parallel lines with different y-intercepts. Formula: y ~ x + (1|group)

Random Intercept + Slope (τ₀, τ₁ > 0): Groups also have different slopes — no fan-out or fan-in. Formula: y ~ x + (1+x|group)

The parameter ρ controls the correlation: ρ > 0 → groups with high intercept also have steep slope (fan-out). ρ < 0 → lines cross each other (fan-in).
GLMM — When to use which likelihood?
The mixed model principle applies to all distribution families:

Gaussian (LMM): Continuous, symmetric DV. y ~ Normal(μ, σ)

Poisson (GLMM): Count data (0, 1, 2, …). Log link: log(λ) = η — λ stays positive.

Gamma (GLMM): Positive, right-skewed data (reaction times, costs). Log link.

Logistic (GLMM): Binary DV (0/1). Logit link: log(p/(1−p)) = η — p stays in (0,1).

In brms: family = poisson(), family = Gamma(link="log"), family = bernoulli()
ℹ (G)LMM Interactive — Help
What do I learn here?
When data have a group structure (persons, schools, clinics), simple regressions are problematic — observations within a group are not independent. Mixed Models solve this through Random Effects: each group gets its own intercept u₀ⱼ, drawn from a common distribution N(0, τ₀).
Recommended exploration
The most important panels
Group lines: Fixed Effect (γ₀₀ + γ₁₀·x) + group-specific deviation u₀ⱼ — Partial Pooling shrinks all lines toward the grand mean

Shrinkage diagram: No-pooling estimate → Partial-pooling estimate; arrows show the pull. Groups with small n are pulled more strongly.

ICC bar: τ₀²/(τ₀²+σ²) — proportion of variance between groups. ICC > 0.05 indicates that a mixed model is needed.

Simpson warning: appears when Complete Pooling reverses the direction of the slope — the classic Simpson's Paradox.
GLM families
Gaussian: continuous data — classic LMM
Poisson: count data (0,1,2,…) — log link
Gamma: positive continuous data — log link
Logistic: 0/1 data — logit link