t <- seq(0, 1, length.out = 50)
X <- matrix(sin(2 * pi * t) + rnorm(50, sd = 0.1), nrow = 1)
fd <- fdata(X, argvals = t)
# Compare GCV for different nbasis
gcv_5 <- basis.gcv(fd, nbasis = 5)
gcv_10 <- basis.gcv(fd, nbasis = 10)
gcv_20 <- basis.gcv(fd, nbasis = 20)
Run the code above in your browser using DataLab