Mathematical Foundations

This chapter explains the ideas and numerical principles that make GAMs work, exploring not just the equations, but why we chose each ingredient and what problem it solves.

magli provides two distinct engines that solve the same penalized regression problem with different statistical machinery. The mathematical foundations are organized into four self-contained chapters:

Overview & Chapter Guide

  • Part I — Shared Foundations (Part I) introduces the shared ideas both backends agree on, explaining what a GAM is, why additive models balance flexibility with interpretability, and how predictions decompose into independent component plots.

  • Part II — The Eilers & Marx Backend (Part II) covers the Eilers-Marx backend, detailing uniform B-splines, discrete difference penalties, SVD data-augmented solver, Generalized Cross Validation (GCV), fast QR+Cholesky grid search, and observation weights.

  • Part III — The Wood Backend (Part III) covers the Wood backend, detailing Simon Wood’s rich basis families (thin plate, cubic, cyclic, P-splines, random effects), null-space constraint absorption, sum-to-zero identifiability, and continuous REML/GCV optimization with approximate F-tests and p-values (Wood 2013).

  • Part IV — Backends Compared (Part IV) provides an in-depth side-by-side comparison of the two backends (numerical methods, scaling, and decision principles) so you can choose the optimal engine for your data.

Where to Start?

Runnable companions

Each backend chapter has an executed, self-checking notebook in the repository that follows the same order as the text, formula by formula:

Every identity in those chapters is recomputed and asserted in the corresponding notebook, and each notebook closes with a pass/fail audit of the head-line checks.