cbase: Compute a circular B-spline basis matrix

View source: R/cbase.R

cbaseR Documentation

Compute a circular B-spline basis matrix

Description

Computes a circular B-spline basis matrix using evenly spaced knots.

Usage

cbase(x, xl = min(x), xr = max(x), nseg = 10, bdeg = 3)

Arguments

x

a vector of argument values, at which the B-spline basis functions are to be evaluated.

xl

the lower limit of the domain of x; default is min(x).

xr

the upper limit of the domain of x; default is max(x).

nseg

the number of B-spline segments (default 10) between xl and xr.

bdeg

the degree of the basis, usually 1, 2, or 3 (default).

Details

If xl is larger than min(x), it wil be adjusted to min(x) and a warning wil be given. If xr is smaller than max(x), it wil be adjusted to max(x) and a warning wil be given.

The design parameters x, xl, xr, ndeg, bdeg and type = 'cbase' are added to the list of attributes.

In a circular basis, the B-splines are wrapped around the boundaries of the domain. Use a circular basis for data like directions or angles. It should be combined with a circular penalty matrix, as computed by cdiff().

Value

A matrix with length(x) rows and nseg columns.

Author(s)

Paul Eilers and Brian Marx

References

Eilers, P.H.C. and Marx, B.D. (2021). Practical Smoothing, The Joys of P-splines. Cambridge University Press.

Eilers, P.H.C., Marx, B.D., and Durban, M. (2015). Twenty years of P-splines, SORT, 39(2): 149-186.

Examples

# Compute and plot a circular B-spline basis matrix
x = seq(0, 360, by = 2)
B = cbase(x, 0, 360, nseg = 8, bdeg = 3)
matplot(x, B, type = 'l', lty = 1, lwd = 2, xlab = 'x', ylab = '')
title('Note how the ends connect smoothly meet at boundaries' )


JOPS documentation built on Sept. 8, 2023, 5:42 p.m.

Related to cbase in JOPS...