dmat: Spline derivative matrix

View source: R/dmat.R

dmatR Documentation

Spline derivative matrix

Description

Computes a derivative matrix for B-splines that can then be used for shape-constraints. It is internally called by shapeConstr and should not be used directly.

Usage

dmat(d, s, knots, ord)

Arguments

d

Non-negative integer giving the order of derivation. Should be between 0 and ord - 2.

s

Sign of the derivative.

knots

Vector of ordered knots from the spline bases.

ord

Non-negative integer giving the order of the spline.

Details

Does the heavy lifting in shapeConstr to create a constraint matrix for shape-constrained B-splines. Only useful for advanced users to create constraint matrices without passing an object to one of the shapeConstr methods.

Value

A matrix of weighted differences that can be used to constrain B-spline bases.

Note

dmat doesn't perform any checks of the parameters so use carefully. In normal usage, checks are done by shapeConstr methods.

Examples

# A second derivative matrix for cubic B-Splines with regularly spaced knots
# Can be used to enforce convexity
cirls:::dmat(2, 1, 1:15, 4)


cirls documentation built on Sept. 13, 2025, 1:09 a.m.