Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

interpSplineCon

(Cubic) Interpolation Spline from "conreg"


Description

From a "conreg" object representing a linear spline,

interpSplineCon()

produces the corresponding (cubic) spline (via package splines' interpSpline()) by interpolating at the knots, thus “smoothing the kinks”.

isIsplineCon()

determines if the spline fulfills the same convexity / concavity constraints as the underlying "conreg" object.

Usage

interpSplineCon(object, ...)
isIsplineCon(object, isp, ...)

Arguments

object

an R object as resulting from conreg().

isp

optionally, the result of interpSplineCon(object, ...); useful if that is already available in the caller.

...

optional further arguments passed to interpSpline().

Value

interpSplineCon()

returns the interpSpline() interpolation spline object.

isIsplineCon()

is TRUE (or FALSE), indicating if the convexity/concavity constraints are fulfilled (in knot intervals).

Author(s)

Martin Maechler

See Also

Examples

cc <- conreg(cars[,"speed"], cars[,"dist"], convex=TRUE)
iS <- interpSplineCon(cc)
(isC <- isIsplineCon(cc)) # FALSE: not strictly convex
## Passing the interpolation spline --- if you have it anyway ---
## is more efficient (faster) :
stopifnot(identical(isC,
                    isIsplineCon(cc, isp = iS)))

## the interpolation spline is not quite convex:
plot(cc)
with(cars, points(dist ~ speed, col = adjustcolor(1, 1/2)))
lines(predict(iS, seq(1,28, by=1/4)),
      col = adjustcolor("forest green", 3/4), lwd=2)

cobs

Constrained B-Splines (Sparse Matrix Based)

v1.3-4
GPL (>= 2)
Authors
Pin T. Ng <Pin.Ng@nau.edu> and Martin Maechler
Initial release
2020-01-20

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.