ARIMA

Today we talked about ARIMA models to use for making predictions in time series data sets/models. They have 3 parts: 1. They use Autoregressive modeling, which is using past points to predict a point. 2. They use differencing to keep constant variance and hold the mean at 0. 3. They use moving averages as well.

These are important because it makes ARIMA one of the most accurate ways of prediction for time series.

I used the globtemp data set from R which gives global mean land/ocean temperature deviations from 1880 - 2015.

library(astsa)
library(quantmod)
## Loading required package: xts
## Loading required package: zoo
## 
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
## 
##     as.Date, as.Date.numeric
## Loading required package: TTR
## Version 0.4-0 included new data defaults. See ?getSymbols.
library(tseries)
library(timeSeries)
## Loading required package: timeDate
## 
## Attaching package: 'timeSeries'
## The following object is masked from 'package:zoo':
## 
##     time<-
library(forecast)
## 
## Attaching package: 'forecast'
## The following object is masked from 'package:astsa':
## 
##     gas
library(xts)
data(globtemp)

First we have to load all these packages to run our ARIMA model. The command we use is auto.arima() which will give us the orders of the autoregressive, differences, and moving average parts of our model and their coefficients.

model <- auto.arima(globtemp)
model
## Series: globtemp 
## ARIMA(1,1,1) with drift 
## 
## Coefficients:
##          ar1      ma1   drift
##       0.3549  -0.7663  0.0072
## s.e.  0.1314   0.0874  0.0032
## 
## sigma^2 estimated as 0.01011:  log likelihood=119.88
## AIC=-231.76   AICc=-231.46   BIC=-220.14

This tells us that our ARIMA model should be (1,1,1) which means 1 degree of autoregression, 1 degree of differencing, and 1 degree of moving average. Our drift factor is .0072 which means there is an upward trend.

Now the best way to use this data is to predict or forecast into the future. I used the command forecast() and put in the number 10 so that I can predict 10 years/units into the future.

forecast1 <- forecast(model, h=10)
forecast1
##      Point Forecast     Lo 80     Hi 80     Lo 95    Hi 95
## 2016      0.8031838 0.6743294 0.9320383 0.6061180 1.000250
## 2017      0.7841177 0.6346035 0.9336320 0.5554555 1.012780
## 2018      0.7819961 0.6219774 0.9420147 0.5372687 1.026723
## 2019      0.7858872 0.6181356 0.9536388 0.5293333 1.042441
## 2020      0.7919120 0.6174348 0.9663893 0.5250721 1.058752
## 2021      0.7986940 0.6179620 0.9794260 0.5222882 1.075100
## 2022      0.8057447 0.6190423 0.9924470 0.5202080 1.091281
## 2023      0.8128907 0.6204288 1.0053525 0.5185456 1.107236
## 2024      0.8200705 0.6220253 1.0181156 0.5171866 1.122954
## 2025      0.8272623 0.6237901 1.0307345 0.5160785 1.138446

This gives us the 10 point predictions along with their prediction intervals at different levels. We can use the plot command to see how these look as well with the rest of our data.

plot(forecast1)

This is a very easy plot to look at because we can see our shaded prediction intervals and the dark line are the point predicitons. This model is very accurate and can be easily interpretted.