时间序列数据的ADF检验—adfuller()函数的模型拟合系数介绍

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

@创建于:20210318
@修改于:20210318

1、背景

在Holt、Holt-Winters(ExponentialSmoothing)、ARMA、ARIMA这样的自回归模型中,模型对时间序列数据的平稳是有要求的,因此,需要对数据或者数据的n阶差分进行平稳检验,而一种常见的方法就是ADF检验,即单位根检验。

在数学中,平稳随机过程(Stationary random process)或者严平稳随机过程(Strictly-sense stationary random process),又称狭义平稳过程。

平稳随机过程是在固定时间和位置的概率分布与所有时间和位置的概率分布相同的随机过程,即随机过程的统计特性不随时间的推移而变化,因此数学期望和方差这些参数不随时间和位置变化。

Ref:百度百科 平稳随机过程

2、单位根检验(Unit Root Test)理论

单位根检验(Unit Root Test)单位根检验是针对宏观经济数据序列、货币金融数据序列中是否具有某种统计特性而提出的一种平稳性检验的特殊方法,单位根检验的方法有很多种,包括ADF检验、PP检验、NP检验等。
Ref:MBA智库百科

单位根检验的零假设是原序列是非平稳的

在这里插入图片描述

Ref:单位根检验详解

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,
)

Ref:如何查看adfuller()函数的模型拟合系数

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值