# spbase: Compute a sparse B-spline basis on evenly spaced knots In JOPS: Practical Smoothing with P-Splines

 spbase R Documentation

## Compute a sparse B-spline basis on evenly spaced knots

### Description

Constructs a sparse B-spline basis on evenly spaced knots.

### Usage

``````spbase(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 `min(x)`). `xr` the upper limit of the domain of `x` (default `max(x)`) . `nseg` the number of evenly spaced segments between `xl` and `xr` (default 10). `bdeg` the degree of the basis, usually 1, 2, or 3 (default).

### Value

A sparse matrix (in `spam` format) with `length(x)` of rows= and `nseg + bdeg` columns.

Paul Eilers

### References

Eilers, P.H.C. and Marx, B.D. (1996). Flexible smoothing with B-splines and penalties (with comments and rejoinder), Statistical Science, 11: 89-121.

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

### Examples

``````library(JOPS)
# Basis  on grid
x = seq(0, 4, length = 1000)
B = spbase(x, 0, 4, nseg = 50, bdeg = 3)
nb1 = ncol(B)
matplot(x, B, type = 'l', lty = 1, lwd = 1, xlab = 'x', ylab = '')
cat('Dimensions of B:', nrow(B), 'by', ncol(B), 'with', length(B@entries), 'non-zero elements' )

``````

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