bsx: Polynomial B-splines with eXtensions

bsxR Documentation

Polynomial B-splines with eXtensions

Description

Generate the B-spline basis matrix for a polynomial spline with derivative restrictions at the boundary knots.

Usage

bsx(
  x,
  df = NULL,
  knots = NULL,
  degree = 3,
  intercept = FALSE,
  Boundary.knots = range(x),
  deriv = NULL
)

Arguments

x

the predictor variable. Missing values are allowed.

df

degrees of freedom; one can specify df rather than knots; bs() then chooses df-degree (minus one if there is an intercept) knots at suitable quantiles of x (which will ignore missing values). The default, NULL, corresponds to no inner knots, i.e., degree-intercept.

knots

the internal breakpoints that define the spline. The default is NULL, which results in a basis for ordinary polynomial regression. Typical values are the mean or median for one knot, quantiles for more knots. See also Boundary.knots.

degree

degree of the piecewise polynomial—default is 3 for cubic splines.

intercept

if TRUE, an intercept is included in the basis; default is FALSE.

Boundary.knots

boundary points at which to anchor the B-spline basis (default the range of the non-NA data). If both knots and Boundary.knots are supplied, the basis parameters do not depend on x. Data can extend beyond Boundary.knots.

deriv

an integer vector of length 2 with values between 0 and degree + 1 giving the derivative constraint order at the left and right boundary knots; an order of 2 constrains the second derivative to zero (f”(x)=0); an order of 1 constrains the first and second derivatives to zero (f'(x)=f”(x)=0); an order of 0 constrains the zero, first and second derivatives to zero (f(x)=f'(x)=f”(x)=0) An order of degree + 1 computes the basis matrix similarly to bs.

Value

A matrix with containing the basis functions evaluated in x.


LasseHjort/cuRe documentation built on July 6, 2023, 1:08 p.m.