# NOT RUN {
library(fda)
y = log10(apply(daily$precav,2,sum))
x = daily$tempav
xbasis = create.fourier.basis(c(1,365),5) # 5 basis functions
# smoothing of the data and extraction of functional data object
xfd=smooth.basis(c(1:365),x,xbasis)$fd
formula = y ~ xfd
# betalist is an optional argument
bbasis = create.fourier.basis(c(1,365),5) # 5 basis functions
betalist = list(bbasis)
freg.model = freg(formula = formula, betalist = betalist)
# Functional variable and two scalar variables
latitude = CanadianWeather$coordinates[,1]
longitude = CanadianWeather$coordinates[,2]
xfdlist = list(xfd, latitude, longitude)
cbasis = create.constant.basis(c(1,365))
betalist = list(bbasis, cbasis, cbasis)
formula = y ~ xfd + latitude + longitude
freg.model = freg(formula = formula, betalist = betalist)
print(freg.model$coefficients)
# }
Run the code above in your browser using DataLab