Syntax
POLY_SPLINE(Y) POLY_SPLINE(Y,5,3) POLY_SPLINE(LIST(Y,X),5,3)
| Argument | Meaning |
|---|---|
Y or LIST(Y,X) | A single series fits Y against elapsed calendar time. A two-series list fits the first series, Y, against the second, X. |
| Knot count | Default 5; range 2–100. Includes both range endpoints. Five knots provide three internal knots. |
| Degree | Default 3; range 1–5. Degree 1 gives connected straight segments. Degree 3 gives a cubic curve with continuous first and second derivatives at internal knots. |
Examples
Yen=SERIES_SINCE(DEXJPUS,20210101) Fit=POLY_SPLINE(Yen,5,3) Curve=EX(Fit,chart) Errors=EX(Fit,residuals) ErrorChart=LINE_CHART(Errors) Summary=EX(Fit,model)
For a two-series relationship, supply Y first and X second:
Relationship=POLY_SPLINE(LIST(UNRATE,CPIAUCSL),5,3)
This example demonstrates syntax. Economic interpretation depends on the series, transformations and period selected.
What the command returns
A slideshow with model statistics, observed points and a dense fitted curve, and residuals over time. A two-series fit also provides a dated actual-versus-fitted chart.
| Extract | Result |
|---|---|
chart | Observed points and fitted spline |
model | Summary with N, degree, knot count, coefficient count, R², adjusted R², RMSE and residual standard error |
fitted, residuals, actual | Dated series usable in later commands |
actual_vs_fitted, residual_chart | Dated diagnostic charts |
knots, beta | Knot locations and B-spline basis coefficients as numeric arrays |
r2, adjusted_r2, rmse, sigma, n | Numeric fit statistics |
slideshow | Complete slideshow |
How the spline is fitted
Base knots are uniformly spaced across the retained predictor range. The command constructs a B-spline basis and estimates all coefficients together by least squares using column-pivoted Householder QR. The basis includes the intercept, so an additional constant is unnecessary.
With K knots and degree d, the model has K + d − 1 coefficients. It requires more observations than coefficients and a full-rank basis. Fewer knots produce a less flexible model.
Two-series fits use exact shared timestamps with finite values in both series. No interpolation or frequency conversion occurs. Aggregate mismatched frequencies before fitting. A time fit uses actual calendar spacing rather than the observation index.
Unlike independent split polynomial fits, the B-spline curve remains connected at internal knots. In a relationship fit, knots lie along X, rather than at selected event dates.
Interpreting the result
This is an unpenalized regression spline. It does not automatically select knot locations, force the curve through every point, or establish causality. Coefficients are basis weights rather than ordinary regression slopes. Statistics describe the fitted sample; no confidence bands or coefficient t-statistics are reported.
RMSE is √(SSE/N); residual standard error is √(SSE/(N − p)). For a constant response fitted to numerical precision, R² is reported as 1. Charts cover the observed predictor range. The numerical predictor holds the endpoint value constant beyond that range.