| Library: | math |
| See also: | FDApca Fouriereval |
| Quantlet: | Fouriertrans | |
| Description: | Calculates the coefficient in applying a basis expansion by using Fourier series. In this case, it is assumed that the data unit can be expressed by a linear combination of finite terms of sine and cosine functions. |
| Usage: | coef = Fouriertrans(tmat ,nbasis) | |
| Input: | ||
| tmat | T x N matrix, the original data matrix | |
| nbasis | scalar, the number of basis functions on which the expansion is computed | |
| Output: | ||
| coef | K x N matrix, the coefficient applying a Fourier basis expansion | |
library("math")
library("smoother")
temp=read("dailtemp") ; read daily temperature data
nbasis = 30 ; set the number of basis functions
tempcoef = Fouriertrans(temp,nbasis); calculation of coefficient matrix
K = rows(tempcoef) ; number of basis functions in algorithm
nresol = 100 ; number of grid points
period = 365 ; period
phi = Fouriereval(K,nresol,period) ; evaluation of basis functions
tempfdval = tempcoef' * phi ; evaluation of data functions
bp = grpcp(tempfdval,0) ; parallel cordinates plot
dispfd = createdisplay(1,1) ; create display
show(dispfd, 1, 1, bp) ; plots lines
setgopt(dispfd,1,1,"title","Temperature Functions")
Produces a plot of functional data.