How to interpret plots of autocorrelation and Partial Autocorrelation using Python

Viewed 1594

I am trying to model time series using ARIMA. I have two columns in my data-frame: monthlydate and sells.

time         sell
1/31/2014   273033
2/29/2014   203019
3/31/2014   225844
4/30/2014   236374
5/31/2014   189666
6/30/2014   242742
7/31/2014   191682
8/31/2014   208270
9/30/2014   236533
10/31/2014  188010
11/30/2014  245185
12/31/2014  224990
1/31/2015   186733
2/28/2015   296641
3/31/2015   234317
4/30/2015   160818
5/31/2015   214937
6/30/2015   226710
7/31/2015   176030
8/31/2015   160991
9/30/2015   205668
10/31/2015  183680
11/30/2015  194428
12/31/2015  643302
1/31/2016   1306566
2/28/2016   2031110
3/31/2016   1756328
4/30/2016   1703885
5/31/2016   1620547
6/30/2016   1862650
7/31/2016   1742188
8/31/2016   1441375
9/30/2016   1666798
10/31/2016  1992165
11/30/2016  1965643
12/31/2016  1315753
1/31/2017   1676141
2/28/2017   1572417
3/31/2017   1442843
4/30/2017   1337359
5/31/2017   1350256
6/30/2017   1090291
7/31/2017   1329138
8/31/2017   1245024
9/30/2017   1246177
10/31/2017  1361814
11/30/2017  1574517
12/31/2017  1035892
1/31/2018   1358912
2/29/2018   1408371
3/31/2018   1239371
4/30/2018   874519
5/31/2018   1025873

Before running ARIMA model I need to figure out parameters like ARIMA(p,d,q) requires three parameters and is traditionally configured manually.

I started plotting the ACF and PACF plots in python and here is the output. I fail to understand what does it indicate and how can we use this plot to build ARIMA model?

enter image description here

enter image description here Many textbook says this:

Autoregression Intuition Consider a time series that was generated by an autoregression (AR) process with a lag of k.

We know that the ACF describes the autocorrelation between an observation and another observation at a prior time step that includes direct and indirect dependence information.

This means we would expect the ACF for the AR(k) time series to be strong to a lag of k and the inertia of that relationship would carry on to subsequent lag values, trailing off at some point as the effect was weakened.

We know that the PACF only describes the direct relationship between an observation and its lag. This would suggest that there would be no correlation for lag values beyond k.

Its difficult to understand. Can it explained in lay man language?

How to interpret above plots? How to find optimal p,d,f parameters using python?

1 Answers

If you want to use the ACF and PACF for lag length determination you want to choose the AR terms according to the cut-off of the PACF and the MA terms according to the cut-off of the ACF. Though you have to be careful in not to choosing too many AR and MA terms.

A similar question has already been answered here and here. With a good free online resource.

Another way to find the ARIMA parameters is using an information criteria

import statsmodels.api as sm
result = {}
for p in range(5):
    for q in range(5):
        arma = sm.tsa.ARIMA(y, order=(p,0,q))
        arma_fit = arma.fit()
        result[(p,q)] = arma_fit.aic

p,q = min(result, key=result.get)
Related