dierckx2fd {DierckxSpline}R Documentation

Translate dierckx and fd objects

Description

Translate a non-periodic object of class dierckx into an object of class fd (functional data, in the fda package), and vice versa. The 'translations' are, however, imperfect, in that many components of each are not present in the other.

Usage

dierckx2fd(object)
fd2dierckx(object) 

Arguments

object an object of class dierckx (for 'dierckx2fd') or fd (for 'fd2dierckx') to be translated into the other class.

Details

The 'translations' do not translate everything.

dierckx2fd
The 'fda' package (as of version 1.2.2) supports B-splines with coincident boundary knots. It recommends Fourier bases for periodic phenomena and does not supporb B-splines with periodic boundary knots. Accordingly, 'dierckx2fd' currently stops with an error message if object[["periodic"]] is TRUE.

Value

'dierckx2fd' converts an object of class 'dierckx' into one of class 'fd'.
'fd2dierckx' converts an object of class 'fd' into one of class 'dierckx'. An object of the other class.

Author(s)

Spencer Graves

References

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

Ramsay, James O., and Silverman, Bernard W. (2006), Functional Data Analysis, 2nd ed., Springer, New York.

Ramsay, James O., and Silverman, Bernard W. (2002), Applied Functional Data Analysis, Springer, New York.

See Also

curfit fd

Examples

x <- 0:24
y <- c(1.0,1.0,1.4,1.1,1.0,1.0,4.0,9.0,13.0,
       13.4,12.8,13.1,13.0,14.0,13.0,13.5,
       10.0,2.0,3.0,2.5,2.5,2.5,3.0,4.0,3.5)
curfit.xy <- curfit(x, y, s=0)

library(fda)
curfit.fd <- dierckx2fd(curfit.xy)
plot(curfit.fd) # as an 'fd' object 
points(x, y) # Curve goes through the points.  

x. <- seq(0, 24, length=241)
pred.y <- predict(curfit.xy, x.) 
lines(x., pred.y, lty="dashed", lwd=3, col="blue")
# dierckx and fd objects match.

curfit2 <- fd2dierckx(curfit.fd)
pred.y2 <- predict(curfit2, x.)
sum(abs(pred.y-pred.y2))/(sum(abs(pred.y)+abs(pred.y2))/2)
# 2.7e-7 
all.equal(knots(curfit.xy, FALSE), knots(curfit2, FALSE))
# TRUE 
all.equal(coef(curfit.xy), coef(curfit2)) 
# "Mean relative  difference: 6.026638e-07"

preserved <- c("from", "to", "n", "g", "periodic", "xlim","ylim")
all.equal(curfit.xy[preserved], curfit2[preserved])
# TRUE 
# Other components are NOT preserved in translation
# and so can NOT be restored.


[Package DierckxSpline version 1.0-9 Index]