我正在尝试使用Dickey Fuller Test检查我的时间序列是否静止。看看我的原始数据,我很确定它们不是静止的。但是,在使用python对我的数据实施Dickey Fuller测试后,结果显示我的时间序列是静止的(具有非常低的p值)。
我的代码和结果如下:
def test_stationarity(timeseries):
#Determing rolling statistics
rolmean = timeseries.rolling(window=7,center=False).mean()
rolstd = timeseries.rolling(window=7,center=False).std()
#Plot rolling statistics:
orig = plt.plot(timeseries, color='blue',label='Original')
mean = plt.plot(rolmean, color='red', label='Rolling Mean')
std = plt.plot(rolstd, color='black', label = 'Rolling Std')
plt.legend(loc='best')
plt.title('Rolling Mean & Standard Deviation')
#plt.savefig('stationarity_{}.png'.format(timeseries.columns.values[0]))
#plt.show(block=False)
#Perform Dickey-Fuller test:
print ('Results of Dickey-Fuller Test:')
dftest = adfuller(timeseries.values.ravel(), autolag='AIC')
dfoutput = pd.Series(dftest[0:4], index=['Test Statistic','p-value','#Lags Used','Number of Observations Used'])
for key,value in dftest[4].items():
dfoutput['Critical Value (%s)'%key] = value
print (dfoutput)
Results of Dickey-Fuller Test:
Test Statistic -7.252678e+00
p-value 1.763304e-10
Lags Used 4.600000e+01
Number of Observations Used 2.031600e+04
Critical Value (1%) -3.430672e+00
Critical Value (5%) -2.861682e+00
Critical Value (10%) -2.566846e+00
有人可以解释一下这怎么可能?是否有任何使用Dickey Fuller测试的假设?