bsplines function

B-spline bases

B-spline bases

These functions generate B-spline basis functions. bspline_basis gives a basis of spline functions. periodic_bspline_basis gives a basis of periodic spline functions.

bspline_basis(x, nbasis, degree = 3, deriv = 0, names = NULL, rg = range(x)) periodic_bspline_basis( x, nbasis, degree = 3, period = 1, deriv = 0, names = NULL )

Arguments

  • x: Vector at which the spline functions are to be evaluated.
  • nbasis: The number of basis functions to return.
  • degree: Degree of requested B-splines.
  • deriv: The order of the derivative required.
  • names: optional; the names to be given to the basis functions. These will be the column-names of the matrix returned. If the names are specified as a format string (e.g., "basis%d"), sprintf will be used to generate the names from the column number. If a single non-format string is specified, the names will be generated by paste-ing name to the column number. One can also specify each column name explicitly by giving a length-nbasis string vector. By default, no column-names are given.
  • rg: numeric of length 2; range of the B-spline basis. To be properly specified, we must have rg[1] < rg[2].
  • period: The period of the requested periodic B-splines.

Returns

  • bspline_basis: Returns a matrix with length(x) rows and nbasis columns. Each column contains the values one of the spline basis functions.

  • periodic_bspline_basis: Returns a matrix with length(x) rows and nbasis columns. The basis functions returned are periodic with period period.

If deriv>0, the derivative of that order of each of the corresponding spline basis functions are returned.

C API

Access to the underlying C routines is available: see c("the ", "list("pomp")", " C API document"). for definition and documentation of the C API.

Examples

x <- seq(0,2,by=0.01) y <- bspline_basis(x,degree=3,nbasis=9,names="basis") matplot(x,y,type='l',ylim=c(0,1.1)) lines(x,apply(y,1,sum),lwd=2) x <- seq(-1,2,by=0.01) y <- periodic_bspline_basis(x,nbasis=5,names="spline%d") matplot(x,y,type='l')

See Also

More on interpolation: covariates, lookup()

Author(s)

Aaron A. King

  • Maintainer: Aaron A. King
  • License: GPL-3
  • Last published: 2025-04-16