splineDesign
Design Matrix for B-splines

Description

Evaluate the design matrix for non-zero B-spline basis functions (or their derivatives).

Usage

splineDesign(knots, x, ord = 4, derivs = integer(nx), outer.ok = FALSE, sparse = FALSE)

Arguments

knots a numeric vector specifying the knots position of a B-spline. This vector is sorted by non-decreasing, and the number of knots must be at least ord. If outer.ok is FALSE, the number of knots must be at least 2*ord-1.
x a numeric vector specifying the values at which the B-spline functions or derivatives are evaluated. If outer.ok is FALSE, the values of x must be in the range of knots[ord] and knots[length(knots) - ord +1].
ord a positive integer specifying the order of the spline. Its value must be at most the number of knots. The default is 4.
derivs an integer vector with the same length as x, and with values between 0 and ord - 1. The default is a vector of zeroes with the same length as x.
outer.ok a logical value. allow values of x that are below knots[ord] or above knots[length(knots)-ord+1]. The basis functions will not add to 1 outside of this range, in fact they will add to 0 outside the range of all the knots, so this is not recommended for use in regresion.
sparse a logical value. This argument is assumed to be FALSE until sparse matrices are supported. Until then, if sparse is set to TRUE, splineDesign returns a warning.

Details

This function returns a design matrix with length(x) rows and length(knots)-ord columns. Each row of the matrix contains the coefficients of the B-splines or the derivative of the B-splines. These splines are defined by the knots vector and evaluated at the values of x. The total number of B-splines is length(knots)-ord because each B-spline is defined by a set of ord successive knots.
Value
returns a matrix described in the DETAILS section.
See Also
bs and ns use splineDesign to construct spline basis functions useful for regression.
Examples
x <- seq(1, 5, by=1/4)
basis <- splineDesign(knots = c(1, 1, 1, 1, 3, 4, 5, 5, 5, 5), x = x)
dbasis <- splineDesign(knots = c(1, 1, 1, 1, 3, 4, 5, 5, 5, 5), x = x,
                       derivs = rep(1,17))
Package splines version 6.1.1-7
Package Index