*Bounty: 50*

*Bounty: 50*

According to ESL, natural cubic basic spline with $K$ knots is represented by $K$ basis function.

However, the `ns()`

function in R with `knots=K`

generates a basis matrix with $K+2$ basis function. This representation seems to add just two and not four constraints in both the boundary regions.

Indeed the documentation says that that the resulting matrix is a $N times df$ matrix, where df = length(knots) + 1 + intercept.

(In addition to this, the resulting plot of `lm(y~ns(x,knots=c(k_1,k_2,...,K_n),intercept=T))`

is not a linear function in the extreme regions)

My question is : is this a different definition of natural cubic spline?