Many things in health don’t change at a steady rate. Risk might stay flat across some ages, then climb quickly. Researchers need a way to let the data draw its own curve instead of forcing a straight line onto it. A restricted cubic spline does this by stitching smooth curved pieces together at chosen points called knots, then keeping the ends of the curve tame. The name comes from the flexible rods draftsmen once bent through fixed points to draw smooth curves.1Encyclopedia of Statistical Sciences. Spline Function: Overview
Smooth Pieces Joined at Knots
A spline is a curve made of pieces. It divides the range of a measurement, such as age, into neighbouring stretches and fits a separate formula on each one.2Wikipedia. Spline (mathematics) The points where one stretch ends and the next begins are the knots.2Wikipedia. Spline (mathematics) In a cubic spline, each piece is a cubic curve, the kind that can rise, level off, and rise again.3The Southwest Journal of Medicine. Restricted Cubic Splines
The pieces are forced to meet at each knot with no jump, no sharp corner, and no sudden change in how fast the curve is bending.3The Southwest Journal of Medicine. Restricted Cubic Splines Any combination of such smooth building blocks stays just as smooth.4Virginia Tech. B-Splines
The word “cubic” matters. Joining straight lines at knots would leave visible corners. Cubic pieces can curve, so they meet smoothly, and cubic is the simplest choice that lets the bends match at the seams. Higher powers add little and are rarely used.
A single cubic formula applied across the whole range of ages is forced into one overall shape, so a bend early on drags the curve elsewhere out of line. Giving each stretch its own formula lets the curve respond to the data locally, so what happens between ages 30 and 50 has little influence on the fit between 60 and 80.
Why Not a Straight Line, a Parabola, or Age Groups
A straight line assumes the effect is the same at every value, which is often untrue.5PubMed Central. Non-linear relationships in clinical research Adding a squared term gives a smooth curve, but it must be a U or an upside-down U.6SAS Support. Restricted Cubic Spline Regression: A Brief Introduction What goes up must come down at the same rate, even when the data show no downturn.6SAS Support. Restricted Cubic Spline Regression: A Brief Introduction Such polynomials also often fit poorly at the ends of the range.6SAS Support. Restricted Cubic Spline Regression: A Brief Introduction
If risk is flat until middle age and then climbs, a squared term will compromise by bending gently everywhere, overstating risk early on and understating it later. A spline makes no such promise about shape, so it can show a flat stretch followed by a climb if that is what the data hold.
Cutting a measurement into groups creates different problems. Putting age into bands treats a 41-year-old and a 59-year-old in the same band as identical.7PubMed Central. Assessing and interpreting the association between continuous covariates and outcomes in observational studies of HIV using splines Differences within each group are ignored.8White Rose ETheses Online. Fractional polynomial and restricted cubic spline models as alternatives to categorising continuous data: applications in medicine The model also quietly assumes risk jumps exactly at the group boundary,7PubMed Central. Assessing and interpreting the association between continuous covariates and outcomes in observational studies of HIV using splines and where to draw the boundaries is an arbitrary choice.7PubMed Central. Assessing and interpreting the association between continuous covariates and outcomes in observational studies of HIV using splines
Bands also cause trouble when a study wants another factor’s effect after removing age’s influence. Older people inside a band still differ from younger ones in the same band. When the grouped variable is used to adjust for age, part of age’s effect leaks through and can distort other findings.7PubMed Central. Assessing and interpreting the association between continuous covariates and outcomes in observational studies of HIV using splines That leftover age difference can be wrongly credited to the other factor, and a smooth age curve removes more of it.
A straight line is still fine when the data really do change steadily, since it is simpler and easier to read. A spline with a near-straight shape tells you that too. Splines test the assumption rather than taking it on faith.
What Makes the Spline Restricted
The ends of a curve are its weak spot. At the extremes there are few data points, so the end pieces of an ordinary spline can swing wildly.9PubMed Central. Non-linear predictor outcome associations Those end pieces are also easily pulled by a few unusual values.9PubMed Central. Non-linear predictor outcome associations A restricted (natural) cubic spline fixes this by making the curve a straight line beyond the outermost knots.10Cross Validated. How different are restricted cubic splines and penalized splines? The ends then behave sensibly and fits are more stable.11PubMed Central. Restricted cubic splines for modelling periodic data12The Stats Geek. Multiple imputation with splines in R using smcfcs The simpler ends also mean fewer numbers need estimating, one fewer than the number of knots.11PubMed Central. Restricted cubic splines for modelling periodic data
Past the first knot on the left and the last knot on the right, the curve stops bending and continues as a straight line sloping up, down, or level. Between the outer knots it can still bend freely, so the restriction costs nothing in the middle where most people are. The straight tails are an assumption, not a discovery: the data there are being extrapolated using a simple rule.
The restriction is not a cure-all. Restricted splines handle complex shapes and resist outliers fairly well, but their shape still depends on how many knots there are and where they sit.9PubMed Central. Non-linear predictor outcome associations
Choosing How Many Knots and Where
The number of knots largely decides how wiggly the curve can be.10Cross Validated. How different are restricted cubic splines and penalized splines? Four knots is a common default, a balance between flexibility and overfitting, meaning chasing random noise.6SAS Support. Restricted Cubic Spline Regression: A Brief Introduction With a small sample, three knots are advised so each stretch has enough people in it.6SAS Support. Restricted Cubic Spline Regression: A Brief Introduction Researchers can also let a selection rule or a test on held-back data pick the number instead of guessing.13MetricGate. Selecting Knots and Degrees for Spline Regression Models
Placement matters too. Knots are usually placed at set percentiles of the data, for example the 10th, 50th and 90th.14PubMed Central. Dose-response meta-analysis of differences in means Percentiles guarantee data around each knot, whereas round values like ages 20, 40 and 60 could leave a stretch nearly empty. Good studies report where their knots were.
The trade-off is that percentile placement puts many knots where data are crowded and few where data are sparse.15PubMed Central. Greedy knot selection algorithm for restricted cubic spline regression The curve can then be too wiggly in crowded regions and too stiff in sparse ones.15PubMed Central. Greedy knot selection algorithm for restricted cubic spline regression Methods that place knots according to the curve’s shape can follow the true pattern better.15PubMed Central. Greedy knot selection algorithm for restricted cubic spline regression
When reading a study, ask whether the knots were chosen before seeing results, whether conclusions held with three versus five knots, and whether the sample was big enough for the number used.
How the Curve Is Built Behind the Scenes
Ordinary regression software never has to learn what a curve is. It turns one measurement into a handful of new columns, each switching on past a knot.16PubMed Central. A review of spline function procedures in R The first new column is age itself, and the others are curved terms that begin to matter only past particular knots. The regression fits these columns as ordinary predictors, and their combined effect traces the curve.
Because of that, the method can be used inside common health models, such as for complications after surgery.17rmsmd.github.io. Standard workflow with restricted cubic splines Two spline curves can also be combined to show how the effect of one measurement changes with another.18PubMed. Modeling of time trends and interactions in vital rates using restricted regression splines
Each helper column gets its own number in the output, but none of them alone is “the effect of age.” Only together do they draw the curve, which is why results are reported as plots rather than single numbers.
Reading a Spline Result in a Study
Because the effect changes across the range, it can’t be summed up in one coefficient.5PubMed Central. Non-linear relationships in clinical research The simplest report is a plot of the curve.5PubMed Central. Non-linear relationships in clinical research Authors may add the slope at a few chosen points to give numbers.5PubMed Central. Non-linear relationships in clinical research
In survival studies, authors pick a reference value such as the median or minimum.19PubMed Central. Graphical methods to illustrate the nature of the relation between a continuous variable and the outcome when using restricted cubic splines with a Cox proportional hazards model They then plot the hazard ratio, the relative risk at each value compared with that reference.19PubMed Central. Graphical methods to illustrate the nature of the relation between a continuous variable and the outcome when using restricted cubic splines with a Cox proportional hazards model A value of 2 at some point means twice the risk at that moment compared with the reference value.19PubMed Central. Graphical methods to illustrate the nature of the relation between a continuous variable and the outcome when using restricted cubic splines with a Cox proportional hazards model
To read such a curve, first find the reference value, where the curve equals 1. Above 1 means higher risk than the reference, and below 1 means lower. Then check the shaded band: if it includes 1, the difference is uncertain. Finally, note where the curve turns, which is often the most useful finding.
The reference choice changes how the plot looks. Moving it shifts the whole curve up or down while the shape stays the same, so compare studies only after checking their reference values.
A U-shaped curve shows what splines can reveal. Risk can be higher at both low and high values, something a straight line would average out and show as nothing. The low point marks the value with the lowest estimated risk, though the uncertainty band shows how precisely that point is pinned down.
The shaded band shows how uncertain the estimate is at each value, and it is usually wider where fewer people were observed. A narrow band in the middle and a wide band at the ends is the normal pattern and not a sign of error. The band reflects sampling uncertainty only; it cannot fix a poor study design or factors the study did not measure.
Common Pitfalls With Splines
Missing data can flatten the curve. When missing values are filled in assuming a straight-line effect, the final curve is biased toward a straight line.20Statalist. Re: st: generating splines in variable with missing data and multiple imputation One common fix is to build the spline columns first and fill them in like any other variable.20Statalist. Re: st: generating splines in variable with missing data and multiple imputation Specialised filling-in methods can also work directly with restricted spline columns.12The Stats Geek. Multiple imputation with splines in R using smcfcs
A modest sample spread across many knots can give a curve that fits the study group closely but would not hold up in a new group of people. The usual remedy is fewer knots, especially when the outcome being studied is rare.
Some warning signs are easy to spot: many knots with only a few hundred people, dramatic bends in the tails where data are thin, no shaded uncertainty band, or knot locations not reported.
To check that a result is robust, refit with a different number of knots, then refit with the knots moved. Conclusions that survive both are more trustworthy. If they flip, treat the shape cautiously.

