GramBS | R Documentation |
Compute the Gram matrix \bm{G}
, i.e., the matrix of inner products between B-splines b_1(x), b_2(x), \ldots
. Precisely, its element is G_{uv} = \int b_u(x)b_v(x)\textrm{d}x
. Such matrix is useful for estimating functional linear models.
The Gram matrix of differentiated B-splines gives the derivative penalty matrix \bm{S}
for O-splines. Precisely, its element is S_{uv} = \int b_u^{(m)}(x)b_v^{(m)}(x)\textrm{d}x
. Such matrix is straightforward to compute using the results of SparseD
; see Examples.
GramBS(xt, d)
xt |
full knot sequence for ordinary B-splines ( |
d |
B-spline order ( |
A sparse matrix of "dsCMatrix" class.
Zheyuan Li zheyuan.li@bath.edu
require(gps)
require(Matrix)
## 11 domain knots at equal quantiles of Beta(3, 3) distribution
xd <- qbeta(seq.int(0, 1, by = 0.1), 3, 3)
## full knots (with clamped boundary knots) for constructing cubic B-splines
xt <- c(0, 0, 0, xd, 1, 1, 1)
## compute Gram matrix of B-splines
G <- GramBS(xt, d = 4)
round(G, digits = 3)
## Gram matrix of differentiated B-splines, i.e., a derivative penalty matrix
## compute derivative penalty matrices of all orders (m = NULL in SparseD)
D <- SparseD(xt, d = 4, gps = FALSE)
S <- lapply(D, crossprod)
lapply(S, round, digits = 1)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.