stats.stationarity.augmented_dickey_fuller

stats.stationarity.augmented_dickey_fuller(y, *, autolag='AIC')

Run an Augmented Dickey-Fuller test on a time series.

Returns a structured pd.Series instead of printing — callers decide how to display the result.

Parameters

Name Type Description Default
y pd.Series Series to test. Must be a non-empty pandas Series without missing values (validated via check_y). required
autolag str Lag-selection criterion forwarded to statsmodels.tsa.stattools.adfuller. Defaults to "AIC". 'AIC'

Returns

Name Type Description
pd.Series pd.Series with the index
pd.Series ["statistic", "p_value", "n_lags", "n_obs", "critical_1%", | | | [pd](`pandas`).[Series](`pandas.Series`) | "critical_5%", "critical_10%"].

Raises

Name Type Description
TypeError If y is not a pandas Series.
ValueError If y contains missing values.

Examples

import numpy as np
import pandas as pd

from spotforecast2_safe.stats.stationarity import (
    augmented_dickey_fuller,
)

rng = np.random.default_rng(0)
y = pd.Series(rng.standard_normal(500))
out = augmented_dickey_fuller(y)
print(out["p_value"] < 0.05)
True