Schumaker: Create a Schumaker Spline

Description Usage Arguments Value References Examples

View source: R/Schumaker.R

Description

Create a Schumaker Spline

Usage

1
2
Schumaker(x, y, ff = "Not-Supplied", Vectorised = TRUE,
  Extrapolation = c("Curve", "Constant", "Linear"))

Arguments

x

A vector of x coordinates

y

A corresponding vector of y coordinates

ff

(Optional) A corresponding vector of gradiants at the data points. If not supplied this is estimated.

Vectorised

This is a boolean parameter. Set to TRUE if you want to be able to input vectors to the created spline. If you will only input single values set this to FALSE as it is a bit faster.

Extrapolation

This determines how the spline function responds when an input is recieved outside the domain of x. The options are "Curve" which outputs the result of the point on the quadratic curve at the nearest interval, "Constant" which outputs the y value at the end of the x domain and "Linear" which extends the spline using the gradiant at the edge of x.

Value

A list with 3 spline functions. Thee first spline is is for the input points, the second spline is the first derivative of the first spline, the third spline is the second derivative. Each function takes an x value (or vector if Vectorised = TRUE) and outputs the interpolated y value (or relevent derivative).

References

Judd (1998). Numerical Methods in Economics. MIT Press

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
x = seq(1,6)
y = log(x)
SSS = Schumaker(x,y, Vectorised = TRUE)
Spline   = SSS[[1]]
SplineD  = SSS[[2]]
Spline2D = SSS[[3]]
xarray = seq(1,6,0.01)
Result = Spline(xarray)
Result2 = SplineD(xarray)
Result3 = Spline2D(xarray)
plot(xarray, Result, ylim=c(-0.5,2))
lines(xarray, Result2, col = 2)
lines(xarray, Result3, col = 3)

s-baumann/schumaker documentation built on May 23, 2019, 5:07 p.m.