@创建于:20210318
@修改于:20210318
文章目录
1、背景
在Holt、Holt-Winters(ExponentialSmoothing)、ARMA、ARIMA这样的自回归模型中,模型对时间序列数据的平稳是有要求的,因此,需要对数据或者数据的n阶差分进行平稳检验,而一种常见的方法就是ADF检验,即单位根检验。
在数学中,平稳随机过程(Stationary random process)或者严平稳随机过程(Strictly-sense stationary random process),又称狭义平稳过程。
平稳随机过程是在固定时间和位置的概率分布与所有时间和位置的概率分布相同的随机过程,即随机过程的统计特性不随时间的推移而变化,因此数学期望和方差这些参数不随时间和位置变化。
2、单位根检验(Unit Root Test)理论
单位根检验(Unit Root Test)单位根检验是针对宏观经济数据序列、货币金融数据序列中是否具有某种统计特性而提出的一种平稳性检验的特殊方法,单位根检验的方法有很多种,包括ADF检验、PP检验、NP检验等。
Ref:MBA智库百科
单位根检验的零假设是原序列是非平稳的。

3、python接口解释
3.1 adfuller API介绍
Ref:官网资料 statsmodels.tsa.stattools.adfuller
pip install statsmodels
from statsmodels.tsa.stattools import adfuller
或者
statsmodels.tsa.stattools.adfuller()
adfuller(
x,
maxlag=None,
regression="c",
autolag="AIC",
store=False,
regresults=False,
)
3.2 参数
x:array_like,1d,要测试的数据系列。
maxlag: 测试中包含的最大延迟,默认为12 *(nobs / 100)^ {1/4}。
regression:{‘c’,‘ct’,‘ctt’,‘nc’}, 包含在回归中的常量和趋势顺序。‘c’:仅限常量(默认值)。 ‘ct’:恒定和趋势。 ‘ctt’:常数,线性和二次趋势。 ‘nc’:没有恒定,没有趋势。
autolag: {‘AIC’,‘BIC’,‘t-stat’,None}自动确定滞后时使用的方法。如果为None,则使用maxlag滞后。如果是’AIC’(默认值)或’BIC’,则选择滞后数以最小化相应的信息标准。基于’t-stat’的maxlag选择。从maxlag开始并使用5%大小的测试来降低延迟,直到最后一个滞后长度的t统计量显着为止。
store:bool,如果为True,则另外返回adf统计信息的结果实例。默认值为False。
regresults:bool,optional,如果为True,则返回完整的回归结果。默认值为False。
Parameters
----------
x : array_like, 1d
The data series to test.
maxlag : int
Maximum lag which is included in test, default 12*(nobs/100)^{
1/4}.
regression : {
"c","ct","ctt","nc"}
Constant and trend order to include in regression.
* "c" : constant only (default).
* "ct" : constant and trend.
* "ctt" : constant, and linear and quadratic trend.
* "nc" : no constant, no trend.
autolag : {
"AIC", "BIC", "t-stat", None}
Method to use when automatically determining the lag length among the
values 0, 1, ..., maxlag.
* If "AIC" (default) or "BIC", then the number of lags is chosen
to minimize the corresponding information criterion.
* "t-stat" based choice of maxlag. Starts with maxlag and drops a
lag until the t-statistic on the last lag length is significant
using a 5%-sized test.
* If None, then the number of included lags is set to maxlag.
store : bool
If True, then a result instance is returned additionally to
the adf statistic. Default is False.
ADF检验实战

本文介绍了ADF单位根检验的基本原理及其在Python中的实现方法。通过实际案例演示了如何利用statsmodels库进行时间序列数据的平稳性检验,并解读了检验结果。
最低0.47元/天 解锁文章
1578

被折叠的 条评论
为什么被折叠?



