Nonlinearity and splines
What question does this help answer?
What the shape of the relationship actually is, which matters whenever risk does not rise in a straight line: age, blood pressure, body mass index and dose-response relationships routinely do not.
Why the usual alternatives fail
Assuming a straight line can miss a U shape entirely and report no association where a strong one exists at both ends. Splitting into quartiles produces a step function that says risk is constant within a quartile and jumps at an arbitrary boundary, which is never biologically true. Choosing an optimal cutpoint by trying many and keeping the best is a multiple-testing exercise whose p-value cannot be believed.
Categories against a spline
How a restricted cubic spline works
Place a small number of knots across the range of the variable, fit a smooth cubic curve between them, and constrain the curve to be linear beyond the outermost knots so the tails, where data are sparse, do not swing wildly. Three to five knots is usually enough; their placement matters less than their number.
Presenting it
- Plot the fitted curve with a confidence band, against the variable in its natural units.
- State the reference value the curve is plotted relative to, since the whole curve moves when it changes.
- Report a test for nonlinearity, not only a test for any association.
- Show where the data actually are: a rug plot or histogram, because a dramatic curve in a region holding twelve patients is not a finding.
- Give a few interpretable contrasts in the text, such as the estimate at the 75th versus the 25th percentile.
Why Mallard may recommend it
Mallard may suggest a spline whenever a continuous exposure or an important confounder is likely to act nonlinearly, and it will question a proposal to categorise a continuous variable without a clinical threshold behind it.
What to watch out for
Cutting a continuous variable into categories is the most common way to handle nonlinearity and among the worst: it discards information, assumes everyone within a category is identical, creates artificial jumps at the boundaries, and when the cutpoint is chosen from the data it inflates the false-positive rate substantially. The opposite error is over-flexibility: enough knots will fit any wiggle in the sample, including the noise.
Clinical example
Question: How does admission blood pressure relate to mortality? Analysis: Model pressure with a restricted cubic spline with four knots and plot the fitted curve, since the relationship is well known to be U-shaped and a linear term would report almost nothing.
- Cubic splines to model relationships between continuous variables and outcomes: a guide for clinicians (opens in a new tab) · Bone Marrow Transplant · doi 10.1038/s41409-019-0679-x
- Variable selection - A review and recommendations for the practicing statistician (opens in a new tab) · Biom J · doi 10.1002/bimj.201700067