periodic {gps} | R Documentation |
Design matrix and general difference matrices for periodic B-splines
Description
For order- periodic B-splines,
pbsDesign
evaluates B-splines or their derivatives at given -values, and
SparsePD
computes general difference matrices of order 1 to .
Usage
pbsDesign(x, xd, d, nDeriv = 0, sparse = FALSE, wrap = TRUE)
SparsePD(xd, d, wrap = TRUE)
Arguments
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. |
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 on domain
can be constructed to satisfy periodic boundary constraints, that is,
,
= 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 , where
are interior knots and
,
are domain endpoints. For order-
B-splines, we replicate the first
interior knots (after adding
) to the right of
for an augmented set of
knots, which spawns
ordinary B-splines. It turns out that periodic B-splines can be obtained by wrapping segments of those ordinary B-splines that stretch beyond
to the start of the domain (a demo is offered by
DemoPBS
).
Note that we must have at least interior knots to do such periodic extension. This means that
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 .
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)