From LM to GLM
Wrong Likelihood Β· Compare fit Β· Link function Β· Distribution choice
Β© Dr. Rainer DΓΌsing Β· Interactive Tools by Claude
Three Scenarios
OLS regression assumes normally distributed errors (Ξ΅). Three scenarios from body image research show what happens when you force an LM anyway β€” and how a GLM with an appropriate distribution resolves the situation.
Scenarios – Please pick one: ↓
Problem
β‘ LM β€” Normal distribution (wrong)
β†’
β‘‘GLM β€” appropriate distribution (right)
β†’
β‘’Fit comparison: AIC & residuals
Sample size n 50
LM with Normal distribution ⚠ Problematic
Log-Likelihood (LM)β€”
AIC (LM)β€”
GLM with appropriate distribution βœ“ Better
Log-Likelihood (GLM)β€”
AIC (GLM)β€”
Residual distribution & AIC comparison
Ξ”AIC (LM βˆ’ GLM)β€”
β–  LM-AIC β€”
β–  GLM-AIC β€”
RMSE (always comparable β€” in y-units; smaller = better)
β–  LM-RMSE β€”
β–  GLM-RMSE β€”
Link Function What the link function does β€” visually
How to read this diagram: On top is the linear predictor Ξ· = a + bΒ·x β€” just like in ordinary linear regression, it can take any value between βˆ’βˆž and +∞. The link function (arrow) maps Ξ· onto the valid range for this distribution family (below) β€” e.g. probabilities in (0,1) for Bernoulli, or positive values for Poisson/Gamma. The five colored points are the same example x-values on top and below β€” the connecting lines show directly how the link function compresses or stretches them to bring them into the valid range.
Worked Example Effect interpretation with concrete numbers
Concepts What you learn here
How do you choose the right family?

Look at the nature of the outcome variable β€” range, discrete/continuous, symmetric/skewed:

  • Bernoulli β€” binary outcomes: diagnoses, success/failure.
  • Poisson β€” count data (0, 1, 2, …). Note: with overdispersion β†’ Negative Binomial.
  • Gamma β€” positive, right-skewed: reaction times, waiting times, costs.
  • Normal/LM β€” continuous, symmetric, no hard zero boundary: z-standardised questionnaire scores, IQ.

Check fit via Posterior Predictive Check Β· AIC/BIC for comparing alternative families.

Go through it systematically: The Likelihood Compass walks through all distribution families β€” with required parameters, priors, and brms syntax for each.

What is a link function β€” and why do you need one?

The problem: The linear predictor Ξ· = a + bΒ·x can take any value (βˆ’βˆž to +∞). But many outcome variables have a restricted range: probabilities lie in (0,1), count rates must be positive.

The solution: A link function transforms the expected value into a range where linear modelling makes sense:

  • Logit link (Bernoulli): log(p/(1-p)) = Ξ· β€” maps p ∈ (0,1) to (βˆ’βˆž,+∞); inversely, every Ξ· gives a p = 1/(1+e^(βˆ’Ξ·)) ∈ (0,1). The S-curve in the plot.
  • Log link (Poisson, Gamma): log(Ξ») = Ξ· β€” maps Ξ» > 0 to (βˆ’βˆž,+∞); inversely, Ξ» = e^Ξ· is always positive. The exponential curve in the plot.
  • Identity link (Normal): E[y] = Ξ· β€” no transformation; the LM is a GLM special case with normal distribution and identity link.
What happens when you choose the wrong likelihood?

The LM minimises RSS β€” which is equivalent to maximum-likelihood estimation under a normal distribution assumption. When this assumption is violated, the estimates can still be computed, but:

  • Predictions fall outside the valid range (p < 0 or p > 1)
  • The log-likelihood is suboptimal β€” AIC/BIC worse
  • Residuals are systematically non-normal
  • Inference (confidence intervals, tests) is biased
Ξ”AIC as a decision guide

AIC penalises poor fit and number of parameters: AIC = βˆ’2β„“Μ‚ + 2k

Rule of thumb for Ξ”AIC = AIC(LM) βˆ’ AIC(GLM):

  • Ξ”AIC < 2: barely any difference
  • Ξ”AIC 2–6: moderate advantage for GLM
  • Ξ”AIC > 10: strong advantage, LM clearly worse

Here you see the Ξ”AIC live. With binary data and count data the advantage of the GLM is typically large β€” with continuous, symmetric data the LM may be sufficient.

β„Ή From LM to GLM β€” Help
What will I learn here?
This tool shows why a linear model (LM) is structurally wrong for certain data types β€” and how a GLM with an appropriate distribution solves the problem.
The three scenarios
Link function β€” briefly explained
The linear predictor Ξ· = a + bΒ·x can take any value (βˆ’βˆž to +∞). But many outcomes have a restricted range:

Logit link (Bernoulli): log(p/(1-p)) = Ξ· β†’ every Ξ· gives a p ∈ (0,1)
Log link (Poisson, Gamma): log(Ξ») = Ξ· β†’ Ξ» = e^Ξ· is always positive
Identity (Normal): E[y] = Ξ· β€” the classical LM
Reading the AIC comparison
Ξ”AIC = AIC(LM) βˆ’ AIC(GLM) β€” the larger, the worse the LM.
Rules of thumb: < 2 = barely any difference Β· 2–10 = moderate advantage Β· > 10 = LM clearly unsuitable.

Important: Both models are evaluated with the same likelihood β€” a fair comparison.
RMSE & Brier score
For the binary and count-data scenarios, the RMSE bar above is essentially the Brier score: the mean squared error between the predicted probability (or expected value) and the actual outcome. It's always directly comparable, but much less sensitive than AIC β€” which is why it often looks surprisingly similar between LM and GLM.

Reason: OLS minimises squared error directly by definition β€” that's literally its own optimisation target. Log-likelihood/AIC, by contrast, punishes overconfident, wrong probability statements much more severely (logarithmically rather than quadratically). So Ξ”AIC can be huge even when the RMSE bars barely differ β€” RMSE is simply the wrong metric here for comparing the models.
Why this matters for Bayes
The choice of likelihood is just as central in Bayes as in MLE. A Bayesian model consists of Likelihood Γ— Prior β€” if you choose the wrong likelihood (e.g. Normal for 0/1 data), the model is structurally wrong, regardless of how good the prior is.
Next β†’ GLM Conditional Distributions: how GLMs model a separate distribution for each x-value
Further Reading
Dunn & Smyth (2018) β€” Generalized Linear Models with Examples in R