python平稳性检验_Python数据分析0.3 用statsmodels进行ADF平稳性检验

#statsmodels用于数据的统计建模分析

#此例为ADF平稳性检验的例子

from statsmodels.tsa.stattools import adfuller as ADF

import numpy as np

#np.random.rand返回100个服从【0,1)之间均匀分布的随机样本值

'''

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.}

)'''

print(ADF(np.random.rand(100)))

结果为:(-11.132232301402519, 3.260491543071536e-20, 0, 99, {'1%': -3.498198082189098, '5%': -2.891208211860468, '10%': -2.5825959973472097}, 35.95266020626107)

-11.132232301402519<'1%'.val

原假设不成立,数据是平稳的。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值