I want to replicate in R figures 5.1 and 5.2 of the Elements of Statistical learning (Hastie et al), . The authors show how to derive a cubic splines. These splines are not in the B-basis.
Can I use package splines
to do this (I want to use it instead of manual coding, hoping the former will be more efficient) ? It seems bs()
and ns()
will only create b/natural splines. Is there a way to obtain simple splines? These would be (equation 5.3 in ESL):
- $h_1(x) = 1$, $h_2(x) = x$
- $h_3(x) = x^2$, * $h_4(x) = x^3$
- $h_5(x) = (x-\xi)^3_+$,
Thanks!
fda
package has some functionality that might be handy but I have never really tried it... $\endgroup$