Regression · Smoothing

Generalized Additive Model (GAM)

Fit a generalized additive model: each continuous predictor enters as a smooth penalized-spline curve (with per-term partial-effect plots, effective degrees of freedom, and a Wald test), other pred...

In the menus Regression › Smoothing › Generalized Additive Model (GAM)

Also searched as gam generalized additive model smooth terms

When to use it

When a predictor's effect on the response is curved rather than a straight line, but you still want an interpretable, additive model: you can read the shape of each predictor's effect one curve at a time, unlike a black-box model.

When not to: Two or more predictors are expected to interact (their combined effect is not simply the sum of their separate smooth curves; a plain additive GAM has no automatic way to capture this), the dataset is too small to support the chosen spline basis dimension for a smooth term, or maximum predictive accuracy matters more than interpretability (an ensemble method may outperform a GAM's additive structure).

Step by step

  1. Open it from the menu

    Click Regression in the menu bar; under Smoothing choose Generalized Additive Model (GAM).

  2. Fill in the form

    Choose the columns: What you want to predict, Curved predictors, Straight-line predictors (optional). The form lists only columns whose type fits each field.

  3. Check the options

    The options start at their defaults: Response family, Spline basis size, Spline degree, Smoothing penalty, Alpha, Confidence level. Change one only when your question needs it.

  4. Run the analysis

    Press Run analysis. The Result Card opens on its Results tab.

What to choose in the form

Fields of the Generalized Additive Model (GAM) form
What you want to predict Response requiredOne numeric or binary or count or categorical column. Response/outcome column. Numeric for Gaussian, two-level or 0/1 for Binomial, non-negative counts for Poisson.
Curved predictors Smooth Terms requiredOne numeric column. Continuous predictor(s) modeled as smooth spline curves: one partial-effect plot per term.
Straight-line predictors (optional) Linear TermsOne numeric or categorical or ordered categorical or binary column. Optional predictor(s) entered linearly (categorical auto-encoded). Leave empty for a pure additive smooth model.
Response familyResponse distribution / link: Gaussian (numeric), Binomial (yes/no), or Poisson (counts). Default: gaussian.
Spline basis sizeBasis dimension per smooth term: larger allows wigglier curves. Must exceed the spline degree and be less than the number of distinct values. Default: 6.
Spline degreeB-spline polynomial degree (3 = cubic, the usual smooth choice). Default: 3.
Smoothing penaltyRoughness-penalty weight λ (≥ 0) applied to every smooth term; the fit minimizes deviance + 2λ∫f''². Larger → smoother/straighter curves; smaller → wigglier. Default: 1.
AlphaSignificance threshold for the per-term Wald tests. Default: 0.05.
Confidence levelConfidence level for partial-effect bands and coefficient intervals. Default: 0.95.

How to read the card

The Results tab starts with what to know first (rows left out, checks that did not pass), then the interpretation in words and the Key Results; charts and assumption checks follow further down. Learn More explains the method in plain words. Read a Result Card covers all four tabs.

What it assumes

Linearity

If it does not hold: If every smooth term in the model has effective degrees of freedom close to 1 (a straight line), the flexible GAM machinery is being used to fit what is really a linear relationship, and a plain linear regression would report the same fit with simpler, more interpretable coefficients.

How to check: Checked directly: the card flags when every smooth term is effectively linear (EDF approximately 1).

A worked example

Modeling penguin body mass as a smooth function of flipper length (Gaussian family, default spline settings).

Result: With the default settings (spline_df = 6, smoothing = 1.0) the flipper-length smooth uses EDF = 4.99 of a possible 5 and the card flags it as near the basis maximum; the Wald test gives p < .001 and pseudo-R-squared = 0.78, against R-squared = 0.76 for a straight-line fit.

Flipper length clearly matters, but the curve is using almost all the flexibility it was given for a two-point gain in R-squared over a straight line, so its bends may be noise. The honest next step is to raise the smoothing penalty and compare AIC: if the EDF falls toward 1 with little loss of fit, the simpler linear regression is the better description.

From the Statistics Library.

The code tabs

Code gives this analysis as Python, R and MATLAB code (and SAS where the tab offers it), reading the data the way KernelStats did. Export sends the card to a report or to slides. See The Code tab.

Understand the statistics

Ask Oobi

Type one of these into Ask Oobi beside your data:

  • How does a penguin's body mass change with flipper length: is the relationship straight, or does it bend?
  • Explain the generalized additive model (GAM) in plain words.
  • What does interaction effect mean?

Last reviewed November 16, 2026.

Report an unclear step