predict {splines2}R Documentation

Evaluate a Spline Basis at specified points

Description

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

Usage

## S3 method for class 'bSpline2'
predict(object, newx, ...)

## S3 method for class 'dbs'
predict(object, newx, ...)

## S3 method for class 'ibs'
predict(object, newx, ...)

## S3 method for class 'mSpline'
predict(object, newx, ...)

## S3 method for class 'iSpline'
predict(object, newx, ...)

## S3 method for class 'cSpline'
predict(object, newx, ...)

## S3 method for class 'bernsteinPoly'
predict(object, newx, ...)

## S3 method for class 'naturalSpline'
predict(object, newx, ...)

Arguments

object

Objects of class bSpline2, ibs, mSpline, iSpline, cSpline, bernsteinPoly or naturalSpline with attributes describing knots, degree, etc.

newx

The x values at which evaluations are required.

...

Optional arguments that are not used.

Details

These are methods for the generic function predict for objects inheriting from class bSpline2, ibs, mSpline, iSpline, cSpline, naturalSpline, or bernsteinPoly. If newx is not given, the function returns the input object.

Value

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

Examples

library(splines2)
x <- seq.int(0, 1, 0.2)
knots <- c(0.3, 0.5, 0.6)
newX <- seq.int(0.1, 0.9, 0.2)

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

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

## for derivative of B-splines
dbsMat <- dbs(x, knots = knots, degree = 2)
predict(dbsMat, 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)

[Package splines2 version 0.4.2 Index]