x=seq(0., 1., length.out=11L)
y=sin(2*pi*x)
f=smbsp(x, y, nki=2L)
d_f=dbsp(f)
xf=seq(0., 1., length.out=101) # fine grid for plotting
plot(xf, d_f(xf)) # derivative estimated by B-splines
lines(xf, 2.*pi*cos(2*pi*xf), col="blue") # true derivative
xk=bsppar(d_f)$xk
points(xk, d_f(xk), pch="x", col="red") # knot positions
Run the code above in your browser using DataLab