I'm using the fourier()
and fourierf()
functions in Ron Hyndman's excellent forecast
package in R. Looking to verify whether the same terms are selected and used in fourier()
and fourierf()
, I plotted a few of the output terms.
Below is the original data using ts.plot(data)
. There's a frequency of 364 in the time series, FYI.
Below is the plot of the terms using fourier(data,3)
. Basically, it looks like mirror images of the existing data.
Looking at just the sin1 term of the output, again, we get some variation that shows similar 364-day seasonality in line with the data above.
However, when I plot the results of the Fourier forecast using fourierf(data,3, 410)
I see the below data. It appears far more smooth than the terms provided by the original fourier
function.
So, I wonder how the results of fourier()
and fourierf()
are related. Is it possible to just see one consolidated Fourier result, so that you can see the sin or cosine result moving through existing data and then through the forecasting period? If not, how can I confirm that the terms created by fourierf()
fit the in-sample data?
I want to use it in an auto.arima
or glm
function with other external regressors like this:
trainFourier<-fourier(data,3)
trainFourier<-as.data.frame(trainFourier)
trainFourier$exogenous<-exogenousData
arima.object<-auto.arima(data, xreg=trainFourier)
futureFourier<-fourierf(data,3, 410)
fourierForecast<-forecast(arima.object, xreg=futureFourier, h=410)
and want to be completely sure that the auto.arima has the proper fitting (using the terms from fourier()
) to what I'll put in under xreg for forecast
(which has terms from a different function, i.e. ffourier()
).