Skip to contents

Builds the B-spline basis matrix by evaluating each normalised truncated power B-spline basis function at the input locations omega. Each column of the matrix corresponds to one basis function.

Usage

build_bspline_design_matrix(omega, knots, k)

Arguments

omega

A numeric vector of input locations at which to evaluate the basis function.

knots

A numeric vector of knots.

k

The degree of the B-spline basis function (must be 0, 1, or 2).

Value

A numeric matrix with length(omega) rows and length(knots) - k - 1 columns, where each column is a normalised B-spline basis function evaluated at omega.

Details

The number of basis functions is given by length(knots) - k - 1. Each column of the matrix is computed using evaluate_bspline_basis.

Examples

knots <- c(0, 1, 2, 3, 4, 5)
omega <- seq(0, 5, length.out = 100)
B <- build_bspline_design_matrix(omega, knots, k = 1)
matplot(omega, B, type = "l", lty = 1, col = 1:ncol(B))