GramBS {gps}R Documentation

Gram matrix of B-splines

Description

Compute the Gram matrix G\bm{G}, i.e., the matrix of inner products between B-splines b1(x),b2(x),b_1(x), b_2(x), \ldots. Precisely, its element is Guv=bu(x)bv(x)dxG_{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 S\bm{S} for O-splines. Precisely, its element is Suv=bu(m)(x)bv(m)(x)dxS_{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 (d2d \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)

[Package gps version 1.2 Index]