Regression · Smoothing

Spline Regression

Fit a flexible spline curve (natural cubic or B-spline) of a numeric outcome on one continuous predictor, with a fitted-curve confidence band, knot markers, and per-region behavior.

In the menus Regression › Smoothing › Spline Regression

Also searched as spline splines regression spline natural spline

When to use it

Model a curved, non-linear relationship between a numeric outcome and a single continuous predictor when a straight line (or even a polynomial) is too rigid, and you want the wiggle to stay local.

When not to: More than one predictor is involved (this function fits exactly one predictor's curve; use a GAM for multiple smooth predictors), you need to extrapolate confidently beyond the observed predictor range (even natural cubic splines' linear-tail guarantee is only as good as the assumption that linearity genuinely continues beyond the data), or the predictor has too few distinct values to support the requested degrees of freedom.

Step by step

  1. Open it from the menu

    Click Regression in the menu bar; under Smoothing choose Spline Regression.

  2. Fill in the form

    Choose the columns: What you want to predict or explain, Column it may depend on. The form lists only columns whose type fits each field.

  3. Check the options

    The options start at their defaults: Spline type, Degrees of freedom, B-spline degree, Confidence level, Alpha. 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 Spline Regression form
What you want to predict or explain Response requiredOne numeric column. Numeric outcome to model.
Column it may depend on Predictor requiredOne numeric column. Single continuous predictor the spline is built on.
Spline typenatural_cubic (cr, linear tails) or b_spline (bs). Default: natural_cubic.
Degrees of freedomFlexibility: number of spline basis functions (statistics.n_basis). More df = wigglier curve (and more overfitting risk). For b_spline the model also fits one additional intercept term on top of these df basis functions; natural_cubic needs no separate intercept. Default: 4.
B-spline degreePolynomial degree of each B-spline piece (B-spline only; 3 = cubic). Default: 3.
Confidence levelConfidence level for the fitted-curve band. Default: 0.95.
AlphaSignificance threshold for the overall F-test. Default: 0.05.

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

Homogeneity of variance (homoscedasticity)

If it does not hold: Heteroscedasticity (residual spread that changes with the fitted value) makes the confidence band around the spline curve too narrow in some regions and too wide in others.

How to check: Breusch-Pagan test on the residuals, reported directly on the card.

Normality (of residuals, not of the raw data)

If it does not hold: Non-normal residuals make the F-test and the confidence band around the spline exact only approximately.

How to check: Jarque-Bera test on the residuals, reported directly on the card.

Independence of observations

If it does not hold: Spline regression (like OLS) assumes rows are independent; time-series or clustered data make the confidence band understate the true uncertainty.

How to check: Not checked by KernelStats: cannot be tested from cross-sectional data alone; stated directly as a standing reminder.

A worked example

A natural cubic spline (df=4) fitting penguin body mass as a function of flipper length.

Result: Two interior knots (df - 2) at the flipper-length tertiles, 192 and 209.3 mm; the curve rises gently below 192 mm (about 15 g per mm) and steeply above it (about 52-59 g per mm); adjusted R-squared = 0.778 versus 0.758 for a straight line. Breusch-Pagan passes; Jarque-Bera flags non-normal residuals (the card notes the CLT makes this minor at n = 342).

The two-point gain in adjusted R-squared says the relationship is mostly linear, with a flatter stretch among the short-flippered birds, a bend the curve and its confidence band show far better than any basis coefficient could. Because that low-flipper stretch is mostly Adelie and Chinstrap and the steep stretch mostly Gentoo, the bend may reflect the species mix rather than a within-species curve.

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 penguin body mass change across the range of flipper length: is the relationship a straight line or does it bend?
  • Explain the spline regression in plain words.
  • What does adjusted R-squared mean?

Last reviewed November 16, 2026.

Report an unclear step