问题描述
我正在分析时间序列数据集,并使用 seasonal_decompose
库中的 statsmodel
函数来获取趋势和季节性行为。我获得了自相关图,所提供的时间序列的分解应该提供一个应该不相关的“剩余”分量。通过观察自相关图,我们如何说自相关函数表明余数确实不相关?
我附上了我用来获得自相关图和获得的图的代码。
fig,ax = plt.subplots(figsize=(20,5))
plot_acf(data,ax=ax)
plt.show()
解决方法
如果自相关的结果接近于零,则特征不相关。我使用 40 的滞后,但您需要根据您的数据调整此值。
plt.clf()
fig,ax = plt.subplots(figsize=(12,4))
plt.style.use('seaborn-pastel')
fig = tsaplots.plot_acf(df['value'],lags=40,ax=ax)
plt.show()
print('values close to 1 are showing strong positive correlation. The blue regions are showing areas of uncertainty')