# linearity test for cublic splines

Consider two models in which a continuous variable is modeled as a restricted cubic spline (RCS) or entered linearly. If one carries out a test for linearity, why are the degrees of freedom for the test equal to the number of knots minus 2. This is noted in the following question.

If there were no linear tail restrictions you would have one d.f. for a basic quadratic and cube term plus each knot. The linear tail restriction gets rid of the quadratic and cube terms plus the two final terms that have to do with differences in cubes. What is left is $k-2$ nonlinear terms if you have $k$ knots. My Course Notes go into more detail in Chapter 2.