forecasting - fourier() vs fourierf() function in R -
i'm using fourier()
, fourierf()
functions in ron hyndman's excellent forecast
package in r. looking verify whether same terms selected , used in fourier()
, fourierf()
, plotted few of output terms.
below original data using ts.plot(data)
. there's frequency of 364 in time series, fyi.
below plot of terms using fourier(data,3)
. basically, looks mirror images of existing data.
looking @ sin1 term of output, again, variation shows similar 364-day seasonality in line data above.
however, when plot results of fourier forecast using fourierf(data,3, 410)
see below data. appears far more smooth terms provided original fourier
function.
so, wonder how results of fourier()
, fourierf()
related. possible see 1 consolidated fourier result, can see sin or cosine result moving through existing data , through forecasting period? if not, how can confirm terms created fourierf()
fit in-sample data?
i want use in auto.arima
or glm
function other external regressors 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 sure auto.arima has proper fitting (using terms fourier()
) i'll put in under xreg forecast
(which has terms different function, i.e. ffourier()
).
figured out problem. using both fda
, forecast
packages. fda
, functional data analysis , regression, has own fourier()
function. if detach fda
, s1 term fourier(data,3)
looks this:
which lines nicely fourier forecast if use ts.plot(c(trainfourier$s1,futurefourier$s1))
moral of story -- watch packages supress, folks!
Comments
Post a Comment