insert.dierckx: Spline Knot Insertion

Description Usage Arguments Details Value Author(s) References See Also Examples

Description

Inserts a knot into a spline object.

Usage

1
2
3
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
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"

DierckxSpline documentation built on May 2, 2019, 6:30 p.m.