smooth.fd | Language Reference for FDA Library
|
>data2fd
> using a fairly large set of basis functions, and
subsequently it was desired to smooth the functional data object
that resulted.
smooth.fd(fdobj, fdParobj)
Lfd
and a smoothing
parameter lambda in slot
lambda
, and this
information is used to further smooth argument
fdobj
.
# Shows the effects of two levels of smoothing # where the size of the third derivative is penalized. # The null space contains quadratic functions. x <- seq(-1,1,0.02) y <- x + 3*exp(-6*x^2) + rnorm(rep(1,101))*0.2 # set up a saturated B-spline basis basisobj <- create.bspline.basis(c(-1,1),81) # convert to a functional data object that interpolates the data. result <- smooth.basis(x, y, basisobj) yfd <- result$fdobj # set up a functional parameter object with smoothing # parameter 1e-6 and a penalty on the 3rd derivative. yfdPar <- fdPar(yfd, 3, 1e-6) yfd1 <- smooth.fd(yfd, yfdPar) # set up a functional parameter object with smoothing # parameter 1 and a penalty on the 3rd derivative. yfdPar <- fdPar(yfd, 3, 1) yfd2 <- smooth.fd(yfd, yfdPar) # plot the data and smooth plot(x,y) # plot the data lines.fd(yfd1, lty=1) # add moderately penalized smooth lines.fd(yfd2, lty=3) # add heavily penalized smooth legend(-1,3,c("0.000001","1"),lty=c(1,3)) # plot the data and smoothing using function plotfit.fd plotfit.fd(y, x, yfd1) # plot data and smooth