bspline: Generate a Cubic B-Spline Basis Matrix

View source: R/bspline.R

bsplineR Documentation

Generate a Cubic B-Spline Basis Matrix

Description

Generate the B-spline basis matrix for a cubic spline with the first and last columns dropped.

Usage

bspline(x, df=NULL, knots=NULL, Boundary.knots = range(x))

Arguments

x

the predictor variable. Missing values are allowed.

df

degrees of freedom; one can specify df rather than knots; the function chooses df-2 inner knots at suitable quantile of x (which will ignore missing values). The default, NULL, corresponds to one inner knots, i.e. df=3.

knots

the internal breakpoints that define the spline. The default is NULL, which corresponds the median for one knot, quantiles for more knots.

Boundary.knots

boundary points at which to anchor the B-spline basis (default the range of the non-NA data).

Author(s)

Haiming Zhou and Timothy Hanson

References

Hastie, T. J. (1992) Generalized additive models. Chapter 7 of Statistical Models in S eds J. M. Chambers and T. J. Hastie, Wadsworth & Brooks/Cole.

See Also

predict.bspline

Examples

require(stats)
basis <- bspline(women$height, df = 5)
newX <- seq(58, 72, length.out = 51)
# evaluate the basis at the new data
predict(basis, newX)

spBayesSurv documentation built on May 31, 2023, 8:17 p.m.