2

constant_all = [38.315546998853549, 40.187217618535399, 43.71380567455396, 45.450748920811293, 50.112269986599735, 59.275158665010736, 65.979556682432815, 106.81142772445702, 122.61124737594076, 160.38976378829483, 109.69662873794118, 86.785774468513864, 73.201627114685436, 62.980558157294979, 60.149903740134562, 54.010569668890867, 54.657627915195405, 57.065262050299623, 59.576109894133168, 61.568376379726971, 64.51074294474725]

我得到了一个类似上面的列表。然后我通过使用运行adfuller测试cadf = ts.adfuller(constant_all),然后我想通过访问p值cadf[0]

但是,我总是得到零。我做错什么了吗?

4

1 回答 1

0

根据文档cadf[0]是测试统计量,而pcadf[1]值是您的情况,大约为 0.959。

为了参考起见,让我们同时添加高 p 值和低p值示例:

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

# Generate random residuals
np.random.seed(0)
errors = np.random.normal(0, 1, 1000)

# Create AR(1) samples for models with and without unit roots
x_unit_root = [0]
x_no_unit_root = [0]
for i in range(len(errors)):
    x_unit_root.append(x_unit_root[-1] + errors[i])
    x_no_unit_root.append(0.9*x_no_unit_root[-1] + errors[i])

# Calculate Augmented Dickey--Fuller p-values
ts.adfuller(x_unit_root)[1], ts.adfuller(x_no_unit_root)[1]
# (0.89251931327396528, 3.8562004970538103e-06)
于 2017-11-25T20:21:13.700 回答