Learn R Programming

splines2 (version 0.2.1)

predict: Evaluate a Spline Basis

Description

This function evaluates a predefined spline basis at (new) given values.

Usage

"predict"(object, newx, ...)
"predict"(object, newx, ...)
"predict"(object, newx, ...)
"predict"(object, newx, ...)
"predict"(object, newx, ...)

Arguments

object
Objects of class bSpline2, ibs, mSpline, iSpline, or cSpline having attributes describing knots, degree, etc.
newx
The x values at which evaluations are required.
...
Optional argument for future usage.

Value

An object just like the object input, except evaluated at the new values of x.

Details

These are methods for the generic function predict for objects inheriting from class bSpline2, ibs, mSpline, iSpline, or cSpline. If newx is not given, the function returns the input object. For object returned by function cSpline, the mSpline and iSpline objects shipped in attributes should not be evaluated by this function if rescale is TRUE. See cSpline for details.

See Also

bSpline for B-spline basis; ibs for integral of B-spline basis; mSpline for M-spline basis; iSpline for I-spline basis; cSpline for C-spline basis.

Examples

Run this code
x <- seq(0, 1, 0.2)
knots <- c(0.3, 0.5, 0.6)
newX <- seq(0.1, 0.9, 0.2)

## for B-spline
bsMat <- bSpline(x, knots = knots, degree = 2)
predict(bsMat, newX)

## for integral of B-spline
ibsMat <- ibs(x, knots = knots, degree = 2)
predict(ibsMat, newX)

## for M-spline
msMat <- mSpline(x, knots = knots, degree = 2)
predict(msMat, newX)

## for I-spline
isMat <- iSpline(x, knots = knots, degree = 2)
predict(isMat, newX)

## for C-spline
csMat <- cSpline(x, knots = knots, degree = 2)
predict(csMat, newX)

Run the code above in your browser using DataLab