I am using
fourier() function of R which has arguments x,h,K. Can any body please explain me what is 'K' in this function and what is the use of it.
Thanks in advance.
Cross Validated is a question and answer site for people interested in statistics, machine learning, data analysis, data mining, and data visualization. It only takes a minute to sign up.Sign up to join this community
You could use any feature selection approach to find an optimal value of $k$.
Feature selection is an important subject in statistics. Explaining it is, however, outside the scope of the question and well covered elsewhere. You can find good references for this on the internet. For example consider chapter 7 of The Elements of Statistical Learning (2nd edition) a very good book on the subject that also happens to be available for free download at the author's website (see link).
There are many tools to perform feature selection. Perhaps the simplest, most intuitive is cross-validation. In the context of the model you try to fit (discrete fourier decomposition), cross-validation can be performed as so:
library(forecast) library(McSpatial) y<-ldeaths n<-length(y) x<-1:n qmax<-floor(n/2)-1
forecast package doesn't include a tool to perform
gcv on Fourier decomposition fit of a time series. To do that, you can use the
fourier function in the
According to the
gcv criterion, the optimal value of
K (this parameter is called
q in the
McSpatial) for the
ldeaths dataset is 21. Now you can re-run the Fourier decomposition of the
ldeaths dataset with this optimal value of
K to obtain you final fit that is a valid