periodic: Design matrix and general difference matrices for periodic...

periodicR Documentation

Design matrix and general difference matrices for periodic B-splines

Description

For order-d periodic B-splines, pbsDesign evaluates B-splines or their derivatives at given x-values, and SparsePD computes general difference matrices of order 1 to d - 1.

Usage

pbsDesign(x, xd, d, nDeriv = 0, sparse = FALSE, wrap = TRUE)

SparsePD(xd, d, wrap = TRUE)

Arguments

x

x-values where periodic B-splines are to be evaluated.

xd

domain knot sequence for periodic B-splines (length(xd) >= d + 1).

d

B-spline order (d \ge 2).

nDeriv

derivative order.

sparse

if TRUE, create a sparse design matrix of "dgCMatrix" class.

wrap

if TRUE, the knots wrapping strategy is used; if FALSE, the linear constraint strategy is used.

Details

These functions perform type-2 construction, by transforming design matrix and general difference matrices for ordinary B-splines to satisfy periodic boundary constraints (see Details). By contrast, pbsDesign and SparsePD in gps perform type-1 construction by basis wrapping.

A spline f(x) on domain [a, b] can be constructed to satisfy periodic boundary constraints, that is, f^{(q)}(a) = f^{(q)}(b), q = 0, 1, ..., degree - 1. These are actually linear equality constraints

Unlike ordinary B-splines, period B-splines do not require explicit auxiliary boundary knots for their construction. The magic is that auxiliary boundary knots will be automatically positioned by periodic extension of interior knots.

Denote the domain knot sequence by s_0, s_1, s_2, \ldots, s_k, s_{k + 1}, where (s_j)_1^k are interior knots and s_0 = a, s_{k + 1} = b are domain endpoints. For order-d B-splines, we replicate the first d - 1 interior knots (after adding b - a) to the right of [a, b] for an augmented set of K = k + d + 1 knots, which spawns p = K - d = k + 1 ordinary B-splines. It turns out that periodic B-splines can be obtained by wrapping segments of those ordinary B-splines that stretch beyond [a, b] to the start of the domain (a demo is offered by DemoPBS).

Note that we must have at least d - 1 interior knots to do such periodic extension. This means that d + 1 domain knots are required at a minimum for construction of periodic B-splines.

Value

pbsDesign returns a design matrix with length(x) rows and length(xd) - 1 columns. SparsePD returns a list of sparse matrices (of "dgCMatrix" class), giving general difference matrices of order 1 to d - 1.

Author(s)

Zheyuan Li zheyuan.li@bath.edu

Examples

require(gps)

## 5 domain knots: three interior knots 0.5, 1.5 and 1.8 in domain [0, 3]
xd <- c(0, 0.5, 1.5, 1.8, 3)

## make a grid
x <- MakeGrid(xd, n = 10)

## construct periodic cubic B-splines
PB1 <- pbsDesign(x, xd, d = 4, wrap = TRUE)
PB2 <- pbsDesign(x, xd, d = 4, wrap = FALSE)

## construct general difference matrices of order 1 to 3
SparsePD(xd, d = 4, wrap = TRUE)
SparsePD(xd, d = 4, wrap = FALSE)

gps documentation built on Nov. 2, 2023, 6:08 p.m.

Related to periodic in gps...