Package 'cubicBsplines'

Title: Computation of a Cubic B-Spline Basis and Its Derivatives
Description: Computation of a cubic B-spline basis for arbitrary knots. It also provides the 1st and 2nd derivatives, as well as the integral of the basis elements. It is used by the author to fit penalized B-spline models, see e.g. Jullion, A. and Lambert, P. (2006) <doi:10.1016/j.csda.2006.09.027>, Lambert, P. and Eilers, P.H.C. (2009) <doi:10.1016/j.csda.2008.11.022> and, more recently, Lambert, P. (2021) <doi:10.1016/j.csda.2021.107250>. It is inspired by the algorithm developed by de Boor, C. (1977) <doi:10.1137/0714026>.
Authors: Philippe Lambert [aut, cre] (Université de Liège / Université catholique de Louvain (Belgium))
Maintainer: Philippe Lambert <[email protected]>
License: GPL-3
Version: 1.0.0
Built: 2024-11-19 05:25:01 UTC
Source: https://github.com/plambertuliege/cubicbsplines

Help Index


Computation of a cubic B-spline basis associated to a given vector of knots

Description

Computation of a cubic B-spline basis associated to a given vector of knots

Usage

Bsplines(x, knots)

Arguments

x

vector of values where the B-spline basis must be evaluated.

knots

vector of knots spanning the desired B-spline basis.

Value

A matrix of dimension length(x) by (length(knots)+2).

Each column of the matrix corresponds to one cubic B-spline in the basis.

Examples

Bsplines(x=runif(20),knots=seq(0,1,length=11))

Computation of the 1st derivative of a cubic B-spline basis associated to a given vector of knots

Description

Computation of the 1st derivative of a cubic B-spline basis associated to a given vector of knots

Usage

D1Bsplines(x, knots)

Arguments

x

vector of values where the 1st derivative of the B-spline basis must be evaluated.

knots

vector of knots spanning the desired B-spline basis.

Value

A matrix of dimension length(x) by (length(knots)+2).

Each column corresponds to (the 1st derivative of) one cubic B-spline in the basis.

Examples

D1Bsplines(x=runif(20),knots=seq(0,1,length=11))

Computation of the 2nd derivative of a cubic B-spline basis associated to a given vector of knots

Description

Computation of the 2nd derivative of a cubic B-spline basis associated to a given vector of knots

Usage

D2Bsplines(x, knots)

Arguments

x

vector of values where the 2nd derivative of the B-spline basis must be evaluated.

knots

vector of knots spanning the desired B-spline basis.

Value

A matrix of dimension length(x) by (length(knots)+2).

Each column of the matrix corresponds to (the 2nd derivative of) one cubic B-spline in the basis.

Examples

D2Bsplines(x=runif(20),knots=seq(0,1,length=11))

Computation of the integral of a cubic B-spline basis over (t0,x) for a given vector of knots

Description

Computation of the integral of a cubic B-spline basis over (t0,x) for a given vector of knots

Usage

IBsplines(t0, x, knots)

Arguments

t0

scalar giving lower value of the integration interval.

x

vector giving the upper values of the integration interval.

knots

vector of knots spanning the desired B-spline basis.

Value

A matrix of dimension length(x) by (length(knots)+2).

Each integrated cubic B-spline is within a given column.

Examples

IBsplines(t0=0,x=runif(20),knots=seq(0,1,length=11))

Trapeze integration from a vector of function values evaluated at quadrature points

Description

Trapeze integration from a vector of function values evaluated at quadrature points

Usage

trapeze(x, fx)

Arguments

x

grid of values for the quadrature (vector).

fx

values of the function on the grid (vector).

Value

vector with a numerical approximation of min(x)max(x)f(t)dt\int_{min(x)}^{max(x)} f(t) dt on the grid using the trapeze method.

Examples

x = seq(-4,2,length=100) ; fx = dnorm(x) ; res = trapeze(x,fx)
cbind(true=pnorm(x),trapeze=res)