python做adf检验

发布时间:2019-06-21 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了python做adf检验脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。

aDF检验是用来检验序列是否平稳的方式
一般来说是时间序列中的一种检验方法
python中可使用现成的工具statsmodels来实现adf检验

import numpy as np 
import statsmodels.tsa.stattools as ts

x = np.array([1, 2, 3, 4, 5, 6, 7])
result = ts.adfuller(x, 1)
PRint result
(-2.6825663173365015, 0.077103947319183241, 0, 7, {'5%': -3.4775828571428571, '1%': -4.9386902332361515, '10%': -2.8438679591836733}, 15.971188911270618)

最参数和返回结果的理解还不够深刻
后头再把参数和返回结果都加上
参数项:

 statsmodels.tsa.stattools.adfuller(x, maxlag=None, regression='c', autolag='aiC', Store=False, regresults=False)[source]¶
 x: 序列,一维数组
 maxlag:差分次数
 regresion:{c:只有常量,
            ct:有常量项和趋势项,
            ctt:有常量项、线性和二次趋势项,
            nc:无任何选项}
 autolag:{aic or bic: default, then the number of lags is chosen to minimize the corresponding information crITerium,
          None:use the maxlag,
          t-stat:based choice of maxlag. Starts with maxlag and drops a lag until the t-statistic on the last lag length is significant at the 95 % level.}

脚本宝典总结

以上是脚本宝典为你收集整理的python做adf检验全部内容,希望文章能够帮你解决python做adf检验所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。