harmaccelLfd <- vec2Lfd(c(0,(2*pi/365)^2,0), c(0, 365))
smallbasis <- create.fourier.basis(c(0, 365), 65)
index <- (1:35)[CanadianWeather$place == "Vancouver"]
VanPrec <- CanadianWeather$dailyAv[,index, "Precipitation.mm"]
lambda <- 1e4
dayfdPar <- fdPar(fd(matrix(0,smallbasis$nbasis,1), smallbasis),
harmaccelLfd, lambda)
VanPrecPos <- smooth.pos(day.5, VanPrec, dayfdPar)
# compute fitted values using eval.posfd()
VanPrecPosFit1 <- eval.posfd(day.5, VanPrecPos$Wfdobj)
# compute fitted values using predict()
VanPrecPosFit2 <- predict(VanPrecPos, day.5)
stopifnot(
all.equal(VanPrecPosFit1, VanPrecPosFit2)
)
# compute fitted values using fitted()
VanPrecPosFit3 <- fitted(VanPrecPos)
# compute residuals
VanPrecRes <- resid(VanPrecPos)
stopifnot(
all.equal(VanPrecRes, VanPrecPos$y-VanPrecPosFit3)
)
Run the code above in your browser using DataLab