Design Matrix for B-splines
Evaluate the design matrix for the B-splines defined by
at the values in
1 2 3 4
a numeric vector of knot positions (which will be sorted increasingly if needed).
a numeric vector of values at which to evaluate the B-spline
functions or derivatives. Unless
a positive integer giving the order of the spline function. This is the number of coefficients in each piecewise polynomial segment, thus a cubic spline has order 4. Defaults to 4.
an integer vector with values between
logical indicating if
logical indicating if the result should inherit from class
A matrix with
length(x) rows and
length(knots) - ord
columns. The i'th row of the matrix contains the coefficients of the
B-splines (or the indicated derivative of the B-splines) defined by
knot vector and evaluated at the i'th value of
Each B-spline is defined by a set of
ord successive knots so
the total number of B-splines is
length(knots) - ord.
spline.des function takes the same arguments but
returns a list with several components including
component is the same as the value of the
Douglas Bates and Bill Venables
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
require(graphics) splineDesign(knots = 1:10, x = 4:7) splineDesign(knots = 1:10, x = 4:7, deriv = 1) ## visualize band structure Matrix::drop0(zapsmall(6*splineDesign(knots = 1:40, x = 4:37, sparse = TRUE))) knots <- c(1,1.8,3:5,6.5,7,8.1,9.2,10) # 10 => 10-4 = 6 Basis splines x <- seq(min(knots)-1, max(knots)+1, length.out = 501) bb <- splineDesign(knots, x = x, outer.ok = TRUE) plot(range(x), c(0,1), type = "n", xlab = "x", ylab = "", main = "B-splines - sum to 1 inside inner knots") mtext(expression(B[j](x) *" and "* sum(B[j](x), j == 1, 6)), adj = 0) abline(v = knots, lty = 3, col = "light gray") abline(v = knots[c(4,length(knots)-3)], lty = 3, col = "gray10") lines(x, rowSums(bb), col = "gray", lwd = 2) matlines(x, bb, ylim = c(0,1), lty = 1)
Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.