Description Usage Arguments Details Value Author(s) References See Also Examples
Inserts a knot into a spline object.
1 2 3 |
object |
An object of class |
at |
A vector of knots to insert. If missing, it uses the midpoints of sort(unique(knots(object, interior=FALSE))). |
... |
ignored |
See Dierckx (1993, pp. 16-22, sec. 1.3.4-1.3.6).
An updated spline representation.
Sundar Dorai-Raj
Dierckx, P. (1991) Curve and Surface Fitting with Splines, Oxford Science Publications.
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"
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.