GramBS: Gram matrix of B-splines

GramBSR Documentation

Gram matrix of B-splines

Description

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.

Usage

GramBS(xt, d)

Arguments

xt

full knot sequence for ordinary B-splines (length(xt) >= 2 * d).

d

B-spline order (d \ge 2).

Value

A sparse matrix of "dsCMatrix" class.

Author(s)

Zheyuan Li zheyuan.li@bath.edu

Examples

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)

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

Related to GramBS in gps...