This function produces the derivative of given order of B-splines. It is an implementation of the close form derivative of B-spline basis based on recursion relation. At knots, the derivative is defined to be the right derivative.

dbs(x, derivs = 1L, df = NULL, knots = NULL, degree = 3L, intercept = FALSE, Boundary.knots = range(x, na.rm = TRUE), ...)

x | The predictor variable. Missing values are allowed and will be kept and returned as they were. |
---|---|

derivs | A positive integer specifying the order of derivative. By
default, it is |

df | Degrees of freedom of the B-spline basis to be differentiated.
One can specify |

knots | The internal breakpoints that define the B-spline basis to be
differentiated. The default is |

degree | Non-negative integer degree of the piecewise polynomial to be differentiated. The default value is 3 for the integral of cubic B-splines. |

intercept | If |

Boundary.knots | Boundary points at which to anchor the B-spline basis
to be differentiated. By default, they are the range of the
non- |

... | Optional arguments for future usage. |

A matrix of dimension `length(x)`

by
`df = degree + length(knots)`

(plus on if intercept is included).
Attributes that correspond to the arguments specified are returned
for usage of other functions in this package.

The function is similar with `splineDesign`

. However,
it provides a more user-friendly interface, a more considerate `NA`

's
handling. Internally, it calls `bSpline`

and generates a basis
matrix for representing the family of piecewise polynomials and their
corresponding derivative with the specified interior knots and degree,
evaluated at the values of `x`

. The function `splineDesign`

in
`splines`

package can also be used to calculate derivative of
B-splines.

De Boor, Carl. (1978). *A practical guide to splines*.
Vol. 27. New York: Springer-Verlag.

`predict.dbs`

for evaluation at given (new) values;
`deriv.dbs`

for derivative method;
`bSpline`

for B-splines;
`ibs`

for integral of B-splines.

library(splines2) x <- seq.int(0, 1, 0.01) knots <- c(0.2, 0.4, 0.7) ## the second derivative of cubic B-splines with three internal knots dMat <- dbs(x, derivs = 2L, knots = knots, intercept = TRUE) ## compare with the results from splineDesign ord <- attr(dMat, "degree") + 1L bKnots <- attr(dMat, "Boundary.knots") aKnots <- c(rep(bKnots[1L], ord), knots, rep(bKnots[2L], ord)) res <- splines::splineDesign(aKnots, x = x, derivs = 2L) stopifnot(all.equal(res, dMat, check.attributes = FALSE))