2021-02-19
ARIMA for time series forecasting in Python
2021-03-02

In time series analysis, the Autocorrelation Function (ACF) and the partial autocorrelation function (PACF) plots are essential in providing the model’s orders such as p for AR and q for MA to select the best model for forecasting.

The basic guideline for interpreting the ACF and PACF plots are as follows:

1. Look for a tail-off pattern in either ACF or PACF.
2. If tail off at ACF → AR model → Cut off at PACF will provide order p for AR(p).
3. If tail off at PACF → MA model → Cut off at ACF will provide order q for MA(q).
4. The tail of at both ACF and PACF → ARMA model

Here is the basic information when looking at ACF and PACF plots.

• The two blue dash lines pointed by purple arrows represent the significant threshold levels. Anything that spikes over these two lines reveal significant correlations.
• When looking at the ACF plot, we ignore the long spike at lag 0 (pointed out by the blue arrow). For PACF, the line usually starts at 1.
• The lag axes will be different depending on the time series data.

AR MODEL

Here are the ACF and PACF plots of the AR(1) model.

Tail-off is observed at the ACF plot. Thus, it’s an AR model. From PACF, the cut-off happens at lag 2. Thus, the order is 2. So it should be AR(2) model.

ACF Plot

PACF Plot

MA Model

Tail off at PACF. Then we know that it’s a MA model. The cut-off is at lag 1 in ACF. Thus, it’s MA(1) model.

Not that there are some more spikes that slightly go above the threshold blue lines like around lag 2 and 4. However, we always want a simplified model. So we usually take a lower lag number and a significant spike like the one at lag 1.

ACF Plot

PACF Plot

ARMA Model

ACF and PACF plots of AR and MA models are very straightforward. However, for real-life times series data set, some ACF and PACF plots are ambiguous.

Let’s look at the following plots.

ACF Plot

PACF Plot

In both ACF and PACF plots, it’s not clear whether they are tailing off or cutting off. That’s where ARMA comes in.

With ARMA, the orders of p and q for AR and MA can be more than one. So testing out a few p and q combinations is advised to get a better score of AIC and BIC. To get the p-value for AR for the ARMA model, we will look at PACF plots. The spikes are at 1 and 3. Thus it’s AR(1) and AR(3). To get the q value, we will look at the ACF plot. The spikes are at 1 and 3. Thus it’s MA(1) and MA(3).

We can try out several different combinations of ARMA(1,1), ARMA(1,3), ARMA(3,1), and ARMA(3,3). Don’t worry about not getting the right orders for these ARMA models because we always do diagnostics for all the models to see their performance. In addition, we also choose the best model by their AIC and BIC scores.

ARIMA Model

The same concept of ARMA is applied in the ARIMA model as well. The only difference between ARMA and ARIMA is the differencing (d) [ ARMA(p,q) vs ARIMA(p,d,q)]. Let’s say we have ARMA(1,1) model. If the time series data need differencing to attain the seasonality, then it should be differenced. Then the model will be ARIMA(1,1,1).

Source:

https://medium.com/@ooemma83/how-to-interpret-acf-and-pacf-plots-for-identifying-ar-ma-arma-or-arima-models-498717e815b6

https://towardsdatascience.com/time-series-models-d9266f8ac7b0

Amir Masoud Sefidian
Machine Learning Engineer