periodic | R Documentation |
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
.
pbsDesign(x, xd, d, nDeriv = 0, sparse = FALSE, wrap = TRUE)
SparsePD(xd, d, wrap = TRUE)
x |
|
xd |
domain knot sequence for periodic B-splines ( |
d |
B-spline order ( |
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. |
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.
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
.
Zheyuan Li zheyuan.li@bath.edu
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.