Why do statsmodels and autocorrelation correlation functions give different results in Python?

I need to get the correlation between two different series A and B, as well as the autocorrelation A and B. Using the correlation functions provided by the statistical models, I got different results, not the same, to calculate the autocorrelation A and calculate the correlation between A and A, why the results are different ?.

Here is an example of the behavior I'm talking about:

import numpy as np
from matplotlib import pyplot as plt
from statsmodels.tsa.stattools import ccf
from statsmodels.tsa.stattools import acf

#this is the data series that I want to analyze
A = np.array([np.absolute(x) for x in np.arange(-1,1.1,0.1)])

#This is the autocorrelation using statsmodels autocorrelation function
plt.plot(acf(A, fft=True))

enter image description here

#This the autocorrelation using statsmodels correlation function
plt.plot(ccf(A, A))

enter image description here

+4
source share
1 answer

Two functions have different default arguments for a boolean argument unbiased. To get the same result as acf(A, fft=True)use ccf(A, A, unbiased=False).

+3

Source: https://habr.com/ru/post/1547349/


All Articles