ARIMA

Autoregressive Integrated Moving Average Models (a.k.a. Box Jenkin’s Model)

Autoregressive Model

AR(p): checking if y_t is a linear combination of y_t-1, y_t-2,…, y_t-p.

\[{y_t} = {\phi_1}{y_(t-1)} + {\phi_2}{y_(t-2)} + ... + {\phi_p}{y_(t-p)} + {\epsilon_t}\] Assume phi_p does not equal 0 and epsilon_t is iid N(0, sigma-squared)

Moving Average Model

MA(q): checking if y_t is a linear combination of epsilon_t-1, epsilon_t-2,…, epsilon_t-q.

\[{y_t} = {\mu} + {\epsilon_t} + {\theta_1}{\epsilon_(t-1)} + {\theta_2}{\epsilon_(t-2)} + ... + {\theta_q}{\epsilon_(t-q)}\] Assume theta_q does not equal 0 and epsilon_t is iid N(0, sigma-squared)

Autoregressive Moving Average Model

ARMA(p,q)

  • p = order for AR

  • q = order for MA

\[{y_t} = {\phi_1}{y_(t-1)} + {\phi_2}{y_(t-2)} + ... + {\phi_p}{y_(t-p)} + {\epsilon_t} + {\mu} + {\theta_1}{\epsilon_(t-1)} + {\theta_2}{\epsilon_(t-2)} + ... + {\theta_q}{\epsilon_(t-q)}\] Assume phi_p and theta_q does not equal 0 and epsilon_t is iid N(0, sigma-squared)

Autoregressive Integrated Moving Average Model

ARIMA(p,d,q)

  • p = order for AR

  • d = differencing

  • q = order for MA

We want zero mean and constant variance over time and if we don’t have that, we take the differences between consecutive means until we have zero mean and constant variance.

Example

There are a couple libraries we have to call to do this problem.

library(quantmod)
## Warning: package 'quantmod' was built under R version 3.4.4
## Warning: package 'xts' was built under R version 3.4.4
## Warning: package 'zoo' was built under R version 3.4.4
library(tseries)
## Warning: package 'tseries' was built under R version 3.4.4
library(timeSeries)
## Warning: package 'timeSeries' was built under R version 3.4.4
## Warning: package 'timeDate' was built under R version 3.4.4
library(forecast)
## Warning: package 'forecast' was built under R version 3.4.4
library(xts)

auto.arima picks p, d and q for you and gives you the model.

data(AirPassengers)
mod = auto.arima(AirPassengers)
mod
## Series: AirPassengers 
## ARIMA(2,1,1)(0,1,0)[12] 
## 
## Coefficients:
##          ar1     ar2      ma1
##       0.5960  0.2143  -0.9819
## s.e.  0.0888  0.0880   0.0292
## 
## sigma^2 estimated as 132.3:  log likelihood=-504.92
## AIC=1017.85   AICc=1018.17   BIC=1029.35
  • p (phi) = 2

  • d = 1

  • q (theta) = 1

The equation from this model is:

\[{y_t} = 0.5960{y_(t-1)} + 0.2143{y_(t-2)} - 0.9819{\epsilon_(t-1)}\]

Now we can see the normal plot and then the forecasted plot. We’ll forcast 10 periods (h=10).

par(mfrow = c(2,1))
plot(AirPassengers)
cast = forecast (mod, h=10)
plot(cast)

We can see the forecast for 10 periods using the ARIMA model. If you look at the plot, you can see the blue line. If you could zoom in more, you’d see that there is a dark blue shaded area and a light blue shaded area. The dark blue is 80% prediction interval and the lighter blue is 95% prediction interval.

Overview

ARIMA lets us make predictions for time series data. Time series is the third part of the class so this is pretty useful to the class. We also expanded on moving averages like we talked about last class as well.