It is well known that we ususally apply the bs() and ns() to get the basis of smoothing spline. But do we really know how the function generate the basis? This note will introduce how the bs() and ns() function in R generate the basis design.

The process of bs() is as below:

And we also offer the code to replicate the result of bs().

We can compare our reuslts and those generated by bs() as below.

For the ns(), we have the process as below:

And then we write our own R code to realize the ns() and we compare the results generated by ns() as below: