简体   繁体   English

您如何在statsmodels ADF测试中设置要测试的滞后次数?

[英]How do you set the number of lags to test in the statsmodels ADF test?

I know you can specify maxlags in the parameters, but whenever I do the output shows that I am using zero lags. 我知道您可以在参数中指定maxlags,但是每当执行此操作时,输出就会显示我正在使用零延迟。 Here's a generic example of the problem I'm having. 这是我遇到的问题的一般示例。 I set maxlag = 1 in this example. 在此示例中,我将maxlag设置为1。 The result however shows that the number of lags used is 0, corresponding to the third parameter in the output. 但是,结果显示,使用的滞后次数为0,与输出中的第三个参数相对应。

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

x = np.array([1,2,3,4,3,4,2,3])
result = ts.adfuller(x, 1) # maxlag is now set to 1

>>> result
(-2.6825663173365015, 0.077103947319183241, 0, 7, {'5%': -3.4775828571428571, '1%': -4.9386902332361515, '10%': -2.8438679591836733}, 15.971188911270618)

I'm thinking there is some built-in determining factor for the number of lags based off my input for the maxlag parameter, but I wasn't able to find anything online. 我以为我可以根据maxlag参数的输入来确定延迟数量的内置确定因素,但是我无法在线找到任何东西。

Could someone please explain this, and possibly how to make the ADF test run with the number of lags I want to input. 有人可以解释一下,也可以解释一下如何使用我要输入的滞后次数进行ADF测试。

maxlag is the largest lag that is used for the autolag search. maxlag是用于最大滞后autolag搜索。

By default the number of lags that are chosen is determined by the smallest AIC for all lags up to maxlag. 默认情况下,所选择的滞后次数由所有滞后直至最大滞后的最小AIC决定。 If you want to have a fixed number of lags, then you need to use autolag=None as argument. 如果要有固定数量的滞后,则需要使用autolag=None作为参数。

see the docstring http://www.statsmodels.org/dev/generated/statsmodels.tsa.stattools.adfuller.html 请参阅文档字符串http://www.statsmodels.org/dev/generated/statsmodels.tsa.stattools.adfuller.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM