spliunes {BoomSpikeSlab} | R Documentation |
Spline Basis Expansions
Description
Spline basis expansions of a continuous variable.
Usage
BsplineBasis(x, knots = NULL, numknots = 3)
MsplineBasis(x, knots = NULL, numknots = 3)
IsplineBasis(x, knots = NULL, numknots = 3)
## S3 method for class 'SplineBasis'
knots(Fn, ...)
Arguments
x |
A numeric vector to be expanded. |
knots |
A numeric vector of knots defining the expansion. The
smallest and largest elements in |
numknots |
If the knot vector is |
Fn |
A spline basis matrix. |
... |
Unused, but required to match the signature of the
|
Details
B-splines are the basis most commonly used for additive regression models.
M-splines are an alternative to B-splines, but are rarely used.
I-splines are integrated M-splines. These are monotonic functions, which is useful in monotonic regression problems. If all regression coefficients are positive then the resulting function is nondecreasing.
Value
XsplineBasis
returns a matrix formed by the spline basis
expansion of x
.
knots(Fn)
returns the knots
attribute of Fn
,
which might be useful in a second call to the basis expansion
function.
Author(s)
Steven L. Scott
References
Bsplines are described in deBoor (2001), "A Practical Guide to Splines". Springer.
Msplines and Isplines are reviewed by Ramsay (1988), Statistical Science pp. 425-461.
Examples
# Plot the B-spline basis for x with knots determined by 3 quantiles.
x <- sort(rnorm(1000))
basis <- BsplineBasis(x, numknots=3)
par(mfrow=c(2,3))
for(i in 1:5) plot(x, basis[, i], type="l")
# Plot the I-spline basis for x with the same knots.
basis <- IsplineBasis(x, numknots=3)
par(mfrow=c(2,3))
for(i in 1:5) plot(x, basis[, i], type="l")
# Bring you own knots...
basis <- BsplineBasis(x, knots = quantile(x, c(.2, .5, .8, .9)))
par(mfrow=c(2,3))
for(i in 1:6) plot(x, basis[, i], type="l")
knots(basis)