Research Workflow

Document Spline Knots and Reuse the Fitted Basis

Treat the basis as part of the model

A spline represents a flexible relationship through several basis columns. The coefficients alone do not identify the fitted curve unless the basis definition is also known. Record spline type, degree or constraints, knot locations, boundary knots and intercept handling.

The Patsy spline documentation demonstrates stateful spline transforms and reuse of stored design information for new data. This matters because rebuilding a basis independently on a prediction sample can change its meaning even when the formula text looks similar.

Choose complexity with a reason

Specify the number and placement of knots using a prespecified rule or an appropriately validated selection procedure. Quantile-based knots depend on the training distribution, so save their numerical locations. Check for tied predictor values or sparse tails that make the intended flexibility poorly supported.

Do not interpret each basis coefficient as an ordinary per-unit effect. Use the fitted curve or contrasts at meaningful predictor values, with uncertainty derived from the full coefficient covariance structure.

Follow a hypothetical prediction error

Suppose a training sample has predictor values spanning 20 to 80, with internal knots at 35, 50 and 65. A later prediction sample spans only 40 to 60. If the software recomputes quantile knots from that new sample, the basis columns no longer represent the same functions used during fitting.

Multiplying the old coefficients by those new basis columns is not a valid application of the original model. Reuse the stored knots and basis configuration. If new values lie outside supported boundaries, inspect the spline implementation’s extrapolation behavior rather than assuming it follows the intended scientific relationship.

Audit the exported model

Save the predictor units and any centering or scaling applied before spline construction. Test predictions for several known inputs by comparing the original fitting environment with the exported implementation. Include boundary values and values just inside and outside the training range.

Report the overall relationship or selected contrasts instead of presenting basis coefficients as if they were directly interpretable clinical effects. If the curve is plotted, show the data coverage and avoid a smooth line that hides sparse regions. A reproducible spline analysis includes the transformation recipe, not just a model name and a table of coefficients.

Source verification: 6 November 2026. Examples are hypothetical.

Related reading

Reading path: Analyze data. Guide 53 of 89. Choose any guide to suit your project.

Research Workflow

Review Convergence Before Trusting a Fitted Model

Separate a numerical stopping message from evidence that the intended optimum and uncertainty estimates are reliable.

Research Workflow

Inspect Residuals Against Fitted Values Before Trusting a Regression

Use residual patterns to distinguish mean-shape problems, changing spread, and observations needing investigation.

Browse this reading pathTools for this stageGuides and downloads for this stage