Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

bsplineS

B-spline Basis Function Values


Description

Evaluates a set of B-spline basis functions, or a derivative of these functions, at a set of arguments.

Usage

bsplineS(x, breaks, norder=4, nderiv=0, returnMatrix=FALSE)

Arguments

x

A vector of argument values at which the B-spline basis functions are to be evaluated.

breaks

A strictly increasing set of break values defining the B-spline basis. The argument values x should be within the interval spanned by the break values.

norder

The order of the B-spline basis functions. The order less one is the degree of the piece-wise polynomials that make up any B-spline function. The default is order 4, meaning piece-wise cubic.

nderiv

A nonnegative integer specifying the order of derivative to be evaluated. The derivative must not exceed the order. The default derivative is 0, meaning that the basis functions themselves are evaluated.

returnMatrix

logical: If TRUE, a two-dimensional is returned using a special class from the Matrix package.

Value

a matrix of function values. The number of rows equals the number of arguments, and the number of columns equals the number of basis functions.

Examples

# Minimal example:  A B-spline of order 1 (i.e., a step function)
# with 0 interior knots:
bS <- bsplineS(seq(0, 1, .2), 0:1, 1, 0)

# check

all.equal(bS, matrix(1, 6))


#  set up break values at 0.0, 0.2,..., 0.8, 1.0.
breaks <- seq(0,1,0.2)
#  set up a set of 11 argument values
x <- seq(0,1,0.1)
#  the order willl be 4, and the number of basis functions
#  is equal to the number of interior break values (4 here)
#  plus the order, for a total here of 8.
norder <- 4
#  compute the 11 by 8 matrix of basis function values
basismat <- bsplineS(x, breaks, norder)

# use sparse Matrix representation to save memory
Basismat <- bsplineS(x, breaks, norder, returnMatrix=TRUE)

# check

class(Basismat)=='dgCMatrix'



all.equal(basismat, as.matrix(Basismat))

fda

Functional Data Analysis

v5.1.9
GPL (>= 2)
Authors
J. O. Ramsay <ramsay@psych.mcgill.ca> [aut,cre], Spencer Graves <spencer.graves@effectivedefense.org> [ctb], Giles Hooker <gjh27@cornell.edu> [ctb]
Initial release
2020-12-16

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.