interpSpline
Create an Interpolation Spline

### Description

Creates an interpolation spline from two numeric vectors, or a formula and an optional data frame.

### Usage

    # Generic function
    interpSpline(obj1, obj2, bSpline = FALSE, period = NULL, na.action = na.fail)
    ## Default S3 method:
    interpSpline(obj1, obj2, bSpline = FALSE, period = NULL, na.action = na.fail)
    ## S3 method for class 'formula':
    interpSpline(obj1, obj2, bSpline = FALSE, period = NULL, na.action = na.fail)

### Arguments

obj1 | a numeric vector or a formula with the form of y~x. If it is a numeric vector, all elements must be distinct.
obj2 | a numeric vector with the same length as obj1 if obj1 is a numeric vector, or an optional data frame in which to evaluate obj1 if it is a formula. If obj1 is a formula and obj2 is missing, then sys.parent(1) is used as the evaluation environment.
bSpline | a logical value. If TRUE, the B-spline representation is returned. Otherwise, the polynomial representation is returned. The default is FALSE.
period | an optional positive number specifying the period for a periodic interpolation spline.
na.action | a function (mapping a data.frame to a data.frame without missing values) to handle missing values. The default, na.fail, causes an error if missing values are found.

### Details

interpSpline is a generic function to create an interpolation spline. Currently, the default invisible method is implemented for the case of two numeric vectors, and the other invisible method interpSpline.formula is implemented for the case of formula representation.
Value

- returns a list object of class "nbSpline" inheriting from "bSpline" and "spline" if bSpline is TRUE.
- returns a list object of class "npolySpline" inheriting from "polySpline" and "spline" if bSpline is FALSE.

The returned list object contains following components:

knots | the knots position of spline.
coefficients | the coefficients of spline.
order | the order of B-spline. It is always 4.

and the attribute "formula".
See Also
splineDesign, polySpline, splineOrder, splineKnots
Examples

    x <- c(1, 2, 3, 5, 8, 13, 21)
    y <- sqrt(x)
    # piecewise polynomial representation
    interpSpline(x, y)
    interpSpline(response~predictor, data.frame(response=y, predictor=x))
    # B-spline representation
    i <- interpSpline(x, y, bSpline = TRUE)
    predict(i, 1:21)$y - sqrt(1:21)

Package splines version 6.1.5-18
Package Index