9
$\begingroup$

In general, I have often heard of "splines" being referred to as "old models", criticized for being prone to overfit the data, and being considered to be only better than "higher order polynomials".

enter image description here

However, splines still seem to be used despite the shortcomings mentioned above.

My Question: Are there any ideal use cases for splines? Are there any industries/types of problems where spline based models are seen as the "dominant methodology" (e.g. survival analysis models for time-to-event data)?

I have heard that at times, spline models are able to "interpolate" data better than other types of statistical models - I have also seen a few authors attempt to use splines to model the "rate parameter function" in a poisson process.

Can anyone please provide comments on this?

$\endgroup$
3
  • 11
    $\begingroup$ These seem like odd "shortcomings", almost ad-hominem in nature. "Old model" = bad??? Hmmm... "Prone to overfit the data", not if you use any of the standard regularization approaches developed a long time ago (see R's mgcv package and Simon Wood's papers). And what alternative technology, e.g., GBMs, RFs, and NNs, don't overfit w/o supplemental regularization? "Only better than higher-order polynomials"... Stone-Weierstrass comes to mind here. $\endgroup$
    – jbowman
    Commented Jan 6, 2022 at 5:01
  • 1
    $\begingroup$ Funny that I accidentally saw your post. I'm actually a fan of splines myself and am the first author of: "Polynomial Trajectory Prediction for Improved Learning Performance" (arxiv.org/pdf/2101.12616.pdf) I think you'd find some appealing arguments there for using polynomials in some cases. $\endgroup$
    – Ido_f
    Commented Jan 6, 2022 at 13:24
  • 4
    $\begingroup$ What role do the graphs play in your post? $\endgroup$ Commented Jan 6, 2022 at 14:50

2 Answers 2

15
$\begingroup$

You have to define what you mean by "ideal" or "best" in this question, but I will give you my two cents none the less.

Are there any ideal use cases for splines?

My (very radical) opinion is that when data are plentiful, a spline makes the most sense to use in the absence of any other information. Frank Harrell provides an excellent rationale for this perspective, which I will repeat now.

There are 2 possibilities (use splines, or don't) and 2 latent truths (the effect of the variable truly is non-linear, or it is linear). There are then 4 outcomes to consider:

  1. We don’t use splines and the effect is linear. In this case, a simple model will suffice and we benefit from lower variance fits.

  2. We use splines and the effect is linear. In this case, we spend extra degrees of freedom unnecessarily, increasing the variance of our fits, but the effect of the variable is appropriately estimated.

  3. We don’t use splines and the effect is non-linear. This has the potential to be catastrophic! Imagine that a variable has an effect on y that looks like $y = x^2$. If $x$ is mean centered, then the linear fit could estimate the effect to be 0 or too small, depending on the distribution of $x$.

  4. We use splines and the effect is non-linear. This would be the best case scenario where we appropriately spend our degrees of freedom.

From this scenario analysis it seems that it is always best to fit a spline to data (again, I will concede to the weaker position that this really depends on the availability of data). Best of all, if we initially fit a spline we can always perform an F test to determine if the spline model explains more variance than a linear effect, thereby informing future models fit to similar data.

That's my opinion, generally. Now, let me offer an example in which splines are really clearly the better choice. Suppose you are modelling some function over the course a day (maybe it is traffic to a website or something). The effect has a strong chance of being non-linear since our lives are largely effected by time (we sleep during some periods thereby leading to lower activity on the website, and are active in other periods). Not only is the effect non-linear, it is cyclic (the activity at 1 minute prior to midnight is approximately the same as the activity 1 minute post midnight). We could potentially model this with a trig function, but a better option is to use a cyclic spline which can a) accommodate the cyclic nature of the phenomenon, and b) avoid model bias in having to specify a function form of the phenomena a priori.

$\endgroup$
3
  • 1
    $\begingroup$ From this scenario analysis it seems that it is always best to fit a spline to data: hmm... really? This seems to be a classic example of bias-variance trade-off. Sometimes it pays to accept bias to reduce variance (no splines), other times the opposite (splines). The example in the last paragraph is nice, though! Also, could you please link explicitly to Frank Harrell's writing? $\endgroup$ Commented Jan 6, 2022 at 14:55
  • $\begingroup$ @RichardHardy I believe the parenthetical immediately after that quoted line addresses the concern of variance. As for referencing any writing from Frank, the rationale was provided in one of his RMS courses. I don't think I have a written text resource, and can remove the reference to him should you think that is more appropriate. $\endgroup$ Commented Jan 6, 2022 at 15:20
  • $\begingroup$ I would not remove the reference, as I think it is better to have one that is not quite detailed than none at all. I am not persuaded by the combination of ...it seems that it is always best... and the parenthetical as the former is just not quite right in my view, but perhaps it is just me. $\endgroup$ Commented Jan 6, 2022 at 15:33
6
$\begingroup$

Splines can be seen as non-parametric interpolation or fitting tools. So, the ideal application would be a case where you don't have a model to describe the variable but need to either interpolate it or produce a smooth version of the data.

Splines are often used in conjunction with other methods. For instance, take a look at linear splines: they model a function as a piece-wise linear function. If you think that your response has a nonlinear relationship to a variable, you could model the variable as a linear spline and enter into your OLS equation. See, mkspline function in State, for instance. You can think of GAM (generalized additive model) as an application of a similar approach, where you can apply a (non-smoothing) spline to a variable before throwing it into a regression.

Cubic (non-smoothing) splines are used to upsample variables, e.g. convert quarterly GDP variable into monthly for a model where the response is monthly.

You seem to describe the smoothing splines in your question, that's a different approach to interpolation altogether. It models the response variable as a low order polynomial piece-wise plus introduces the roughness penalty to make the output smooth.

Summarizing, there are many different spline applications used in the industry, some of them are stand-alone (like interpolation) and the others are integrated in other techniques such as regressions.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.