http://www.rdatamining.com/examples/time-series-forecasting
Time Series Forecasting
This example shows time series forecasting of Euro-AUD exchange rates with the with the ARIMA and STL models. The data used are historical currency exchange rates from January 1999 to June 2014 provided by the European Central Bank. This example was produced with R Markdown. The Rmd and R source code files are provided at the bottom of this page. 1. Downloading data from European Central BankDownload data from the European Central Bank athttp://www.ecb.europa.eu/stats/exchange/eurofxref/html/index.en.html.
2. Checking data
3. Forecasting with ARIMAThe code below shows that there are no data for weekends or public holidays.
Based on above result, there are about 256 values per year, so the windows size is set to 256 in time series analysis in section 5. Another way is to fill weekends and public holidays with values in the previous populated days.
4. Forecasting with STL
5. FunctionsBelow are two source files used in section 3 and 4. File forecast.RIt provides functions for forecasting with ARIMA and STL. > File plotForecastResult.RIt provides a function for ploting time series forecasting result, incl. trend, forecast and bounds.
|