Forecasting time series using R by Prof Rob J Hyndman
Contents
The following are my learnings from the Meetup talk by Prof Hyndman.
- The following are the relevant timeseries based packages in
R
forecast
tseries
Mcomp
fma
expsmooth
fpp2
- Completely automated forecasting came out of the need to generate forecasts for thousands of series every week
- Surprisingly good forecast is Naive for stock markets
- Drift method - Random walk + average of first and last observation
- croston : used in supply chain forecasting when the demand is intermittent
- forecast class
- original series, point forecast, prediction interval, forecasting method, residuals and in-sample one step forecasts
- MAPE is not useful when the actual value is close to 0 as MAPE shoots
- Also relevant for only if the target variable has a natural 0 and the target variable is always greater than equal to 0
- MASE is better as it scale variant - stable measure of scale. the mean absolute error is scaled by mean one step forecast error for the training sample
\begin{equation} C = W\log_{2} (1+\mathrm{SNR}) \end{equation}
\begin{equation} MASE = n^{-1} \sum^n_{t=1} { |y_t-f_t| \over q1 } \end{equation}
- 10 years of effort to develop the statistical properties of exponential methods
- All the math is covered in “Forecasting with Exponential Smoothing”
- 5 Types of trend, 3 Types of Seasonality - 15 Models with Additional error
- Trend
- None
- Additive
- Damped Additive
- Multiplicative
- Damped Multiplicative
- Seasonality
- None
- Additive
- Multiplicative
- Trend
- 5 Types of trend, 3 Types of Seasonality - 15 Models with Multiplicative error
- Trend
- None
- Additive
- Damped Additive
- Multiplicative
- Damped Multiplicative
- Seasonality
- None
- Additive
- Multiplicative
- Trend
- ETS function can fit 30 types of models - (Error, Trend, Seasonal)
- 11 of them are numerically unstable
- 19 of them are the ones which algo checks out
- Damped Trend
- Starts off with a trend and then goes down
- Auto ETS works better than any other method for first 4 periods for all seasonal time series
- Why use automated forecasts?
- Most experts can’t beat automated forecasts
- Not everyone is an expert
- Many industries needed thousands of forecasts
- Box Cox to stabilize variance
- Animation of a set of graphs is possible in
beamer
fpp2
builds onarima
from thebase
packageets()
can only fit maximum period of24
Arima()
has a max period of350
but runs out of memory if period>200
STL
approach works pretty well. It allows decomposition of any frequencydshw
allows two seasonal periodsforecast
function takes several types oftimeseries
objects