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]

I got a list like the above. And then I run the adfuller test by using cadf = ts.adfuller(constant_all) and then I want to access the p-value by cadf[0].

However, I always got zero. Have I done anything wrong?

fuglede
  • 17,388
  • 2
  • 54
  • 99
JOHN
  • 1,411
  • 3
  • 21
  • 41

1 Answers1

0

According to the documentation, cadf[0] is the test statistic while cadf[1] is the p-value which, in your case, is about 0.959.

For the sake of reference, let us also add both high and low p-value examples:

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)
fuglede
  • 17,388
  • 2
  • 54
  • 99