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.}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值