| dbs {splines2} | R Documentation |
Produces the derivatives of given order of B-splines.
dbs( x, derivs = 1L, df = NULL, knots = NULL, degree = 3L, intercept = FALSE, Boundary.knots = NULL, ... )
x |
The predictor variable. Missing values are allowed and will be returned as they are. |
derivs |
A positive integer specifying the order of derivative. The
default value is |
df |
Degree of freedom that equals to the column number of the returned
matrix. One can specify |
knots |
The internal breakpoints that define the splines. The default
is |
degree |
A nonnegative integer specifying the degree of the piecewise
polynomial. The default value is |
intercept |
If |
Boundary.knots |
Boundary points at which to anchor the splines. By
default, they are the range of |
... |
Optional arguments that are not used. |
This function provides a more user-friendly interface and a more consistent
handling for NA's than splines::splineDesign() for derivatives
of B-splines. The implementation is based on the close form recursion
formula. At knots, the derivative is defined to be the right derivative
except at the right boundary knot.
A numeric matrix of length(x) rows and df columns if
df is specified or length(knots) + degree +
as.integer(intercept) columns if knots are specified instead.
Attributes that correspond to the arguments specified are returned
mainly for other functions in this package.
De Boor, Carl. (1978). A practical guide to splines. Vol. 27. New York: Springer-Verlag.
bSpline for B-splines;
ibs for integrals 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))