ARIMA Time Series 101

Forecasting Product Demand in R

Aric LaBarr, Ph.D.

Senior Data Scientist, Elder Research

Other DataCamp time series content

Forecasting Product Demand in R

What is an ARIMA Model?

  • Auto Regressive Models

  • Integrated

  • Moving Average

Forecasting Product Demand in R

Integrated - Stationarity

  • Does your data have a dependence across time?
  • How long does this dependence last?

  • Stationarity

    • Effect of an observation dissipates as time goes on
    • Best long term prediction is the mean of the series
    • Commonly achieved through differencing
Forecasting Product Demand in R

Differencing

Typically used to remove trend...

$$ Y_{t} - Y_{t-1} $$

... or seasonality

$$ Y_{t} - Y_{t-12} $$

Forecasting Product Demand in R

Autoregressive (AR) Piece

  • Autoregressive Models
    • Depend only on previous values - called lags
    • $ Y_t = \omega_0 + \alpha_1 Y_{t-1} + \alpha_2 Y_{t-2} + ... + \varepsilon_t $
    • Long-memory models - effect slowly dissipates
Forecasting Product Demand in R

Moving Average (MA) Piece

  • Moving Average Models
    • Depend only on previous "shocks" or errors
    • $ Y_t = \omega_0 + \varepsilon_t + \beta_1 \varepsilon_{t-1} + \beta_2 \varepsilon_{t-2} + ... $
    • Short-memory models - effects quickly disappear completely
Forecasting Product Demand in R

Training vs. Validation

M_t <- bev_xts[,"M.hi"] + bev_xts[,"M.lo"]
Forecasting Product Demand in R

Training vs. Validation

M_t_train <- M_t[index(M_t) < "2017-01-01"]
M_t_valid <- M_t[index(M_t) >= "2017-01-01"]
Forecasting Product Demand in R

How to Build ARIMA Models?

auto.arima(M_t_train)
Series: M_t_train 
ARIMA(4,0,1) with non-zero mean 

Coefficients:
         ar1      ar2     ar3     ar4      ma1       mean
      1.3158  -0.5841  0.1546  0.0290  -0.6285  2037.5977
s.e.  0.3199   0.2562  0.1534  0.1165   0.3089    87.5028

sigma^2 estimated as 67471:  log likelihood=-1072.02
AIC=2158.05   AICc=2158.81   BIC=2179.31
Forecasting Product Demand in R

Let's practice!

Forecasting Product Demand in R

Preparing Video For Download...