插值警告:Python中的KPSS测试与statsmodels

b4lqfgs4  于 2023-10-21  发布在  Python
关注(0)|答案(1)|浏览(189)

当我在代码下面运行时,我会收到特定的警告

import numpy as np
from statsmodels.tsa.stattools import kpss
kpss(np.random.choice(range(-1000,1000),10000))

警告消息

<stdin>:1: InterpolationWarning: The test statistic is outside of the range of p-values available in the
look-up table. The actual p-value is greater than the p-value returned.

是否可以只忽略此警告,而不影响代码文件其他部分中可能出现的任何其他警告的显示

sy5wg1nm

sy5wg1nm1#

一种方法是通过从statsmodels.tools.sm_exceptions导入warning模块和InterpolationWarning来静音插值警告:

import warnings
from statsmodels.tools.sm_exceptions import InterpolationWarning
warnings.simplefilter('ignore', InterpolationWarning)

现在,运行:

import numpy as np
from statsmodels.tsa.stattools import kpss
kpss(np.random.choice(range(-1000,1000),10000))

输出

(0.269901614649574,
 0.1,
 11,
 {'10%': 0.347, '5%': 0.463, '2.5%': 0.574, '1%': 0.739})

相关问题