4

I'm using the statsmodels.graphics.tsaplots module to plot an ACF or a PACF graph using time series data. I've added an example plot below:

Example ACF Plot

Is there any way of getting the individual values for each lag (i.e. each blue circle), as well as the corresponding value of the blue area for each lag? The reason why I need the blue area values is that sometimes the area might expand over the higher lags. Example: ACF with growing blue area

I've tried Retrieve XY data from matplotlib figure but it did not help me in this instance.

The idea for this would be to automatically check the significance of each lag (i.e. if the lag is in the blue area or not)

Any help would be appreciated :)

Thank you

AMSD
  • 43
  • 1
  • 4

1 Answers1

2

You can get the numbers directly using the acf and pacf functions, by passing the alpha parameter. For example:

import statsmodels.api as sm

acf, ci = sm.tsa.acf(endog, alpha=0.05)
pacf, ci = sm.tsa.pacf(endog, alpha=0.05)

The confidence intervals are centered around the (P)ACF values, but you can re-center them around zero (to get the blue shaded region in the chart) by subtracting the (P)ACF values. See https://github.com/statsmodels/statsmodels/issues/6851#event-3511269194 for more details about that.

cfulton
  • 2,855
  • 2
  • 14
  • 13
  • Thank you so much! Worked perfectly :) The Github link definitely helped with working out the confidence values. – AMSD Jul 06 '20 at 11:55