Could one explain how these three parameters change the behaviour of this "wiggle curve" In particular, I am trying to understand b-splines and m-splines.

My limited understanding is as follows:

  • knots - defines the number of turning points within curve
  • degrees of freedom - specifies slightly similar information as knots? defines the number that the line will be splitted?
  • degree - this is the most confusing part, what does this do?

Boundary knots - the ones that are in the start and in the end of the line?

Internal knots - knots somewhere within the line?


1 Answer 1


In essence, splines are piecewise polynomials, joined at points called knots. The degree specifies the degree of the polynomials. A polynomial of degree 1 is just a line, so these would be linear splines. Cubic splines have polynomials of degree 3 and so on. The degrees of freedom ($\mathrm{df}$) basically say how many parameters you have to estimate. They have a specific relationship with the number of knots and the degree, which depends on the type of spline.

For B-splines: $\mathrm{df} = k + \mathrm{degree}$ if you specify the knots or $k = \mathrm{df} - \mathrm{degree}$ if you specify the degrees of freedom and the degree. For natural (restricted) cubic splines: $\mathrm{df} = k - 1$ if you specify the knots or $k = \mathrm{df} + 1$ if you specify the degrees of freedom.

As an example: A cubic spline ($\mathrm{degree}=3$) with $4$ (internal) knots will have $\mathrm{df} = 4 + 3 = 7$ degrees of freedom. Or: A cubic spline ($\mathrm{degree}=3$) with 5 degrees of freedom will have $k = 5 - 3 = 2$ knots.

The higher the degrees of freedom, the "wigglier" the spline gets because the number of knots is increased.

The Boundary knots are the outermost two knots, ususally (but not always) placed at the minimum and maximum of $x$. The other knots are called internal knots and when I talked about the number of knots I was always referring to the internal knots.

Let's see some illustrations. In the scatterplots below you see some artifical data together with the spline fits of different degrees but the same amount of knots ($k = 3$). The knots are indicated by dashed vertical lines (Boundary knots by red dashed lines) and are placed at the 25th, 50th and 75th percentile of $x$. The first plot shows a linear spline ($\mathrm{degree} = 1$), the second one a quadratic spline ($\mathrm{degree} = 2$) and the third is a cubic spline with $\mathrm{degree} = 3$.


In the next plot, you see three cubic splines with different degrees of freedom. As before, the knots are shown as dashed vertical lines. With increasing degrees of freedom, the number of knots gets larger (from 1 to 3 to 5). The spline gets wigglier although the difference is only really noticeable between the first and second plot.


  • 1
    $\begingroup$ Those are very helpful illustrations! Did you make them yourself or do you have a source? :-) $\endgroup$
    – Nonya
    Aug 1, 2021 at 17:21
  • 1
    $\begingroup$ @Nonya Thank you. I made those illustrations myself using R. $\endgroup$ Aug 1, 2021 at 18:44

Your Answer

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

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