insert.dierckx {DierckxSpline}R Documentation

Spline Knot Insertion

Description

Inserts a knot into a spline object.

Usage

insert(object, ...)
## S3 method for class 'dierckx':
insert(object, at, ...)

Arguments

object An object of class dierckx.
at A vector of knots to insert. If missing, it uses the midpoints of sort(unique(knots(object, interior=FALSE))).
... ignored

Details

See Dierckx (1993, pp. 16-22, sec. 1.3.4-1.3.6).

Value

An updated spline representation.

Author(s)

Sundar Dorai-Raj

References

Dierckx, P. (1991) Curve and Surface Fitting with Splines, Oxford Science Publications.

See Also

curfit

Examples

xi <- 1:10
yi <- sin(xi) 
spli <- curfit(xi, yi, s=10)
plot(xi, yi) 
lines(spli)

spli2 <- insert(spli)
lines(spli2, col="red")
kni <- knots(spli, FALSE) # 1 1 1 1 10 10 10 10 
all.equal(c(kni[1:4], 5.5, kni[5:8]), knots(spli2, FALSE))
# add 1 knot at 5.5  
ci <- coef(spli)
ci2 <- coef(spli2)
all.equal(c(ci[1], 0.5*(ci[-1]+ci[-4]), ci[4]), ci2)
# "Mean relative  difference: 2.700131e-08"

[Package DierckxSpline version 1.1-2 Index]