x=seq(0, 5, length.out=101)
# cubic basis matrix
n=3
m=bsc(x, xk=c(rep(0, n+1), 1:4, rep(5, n+1)), n=n)
matplot(x, m, t="l")
stopifnot(all.equal.numeric(c(m), c(splines::bs(x, knots = 1:4, degree = n, intercept = TRUE))))
Run the code above in your browser using DataLab