Why do statsmodels's correlation and autocorrelation functions give different results in Python?
numpy, python, statsmodels
Solution
The two functions have different default arguments for the boolean `unbiased` argument. To get the same result as `acf(A, fft=True)`, use `ccf(A, A, unbiased=False)`.
Problem
I need to obtain the correlation between two different series A and B as well as the autocorrelations of A and B. Using the correlation functions provided by statsmodels I got different results, it's not the same to calculate the autocorrelation of A and to calculate the correlation between A and A, Why are the results 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's autocorrelation function plt.plot(acf(A, fft=True)) ``` ``` #This the autocorrelation using statsmodels's correlation function plt.plot(ccf(A, A)) ```