I used autocorrelation_plot
to plot the autocorrelation of a straight line:
import numpy as np
import pandas as pd
from pandas.plotting import autocorrelation_plot
import matplotlib.pyplot as plt
dr = pd.date_range(start='1984-01-01', end='1984-12-31')
df = pd.DataFrame(np.arange(len(dr)), index=dr, columns=["Values"])
autocorrelation_plot(df)
plt.show()
Then, I tried using autocorr()
to calculate the autocorrelation with different lags:
for i in range(0,366):
print(df['Values'].autocorr(lag=i))
The output is 1 (or 0.99) for all the lag. But it is clear from the correlogram that the autocorrelation is a curve rather than a straight line fixed at 1.
Did I interpret the correlogram incorrectly or did I use the autocorr()
function incorrectly?