Skip to main content
Version: v5

unit_root

Perform the Augmented Dickey-Fuller (ADF) unit root test.

The ADF test checks whether a series has a unit root - a sign of non-stationarity. Rejecting the null hypothesis indicates the series is stationary.

Examples​

from openbb import obb
obb.econometrics.unit_root(column='close', data=[{'date': '2023-01-02', 'open': 110.0, 'high': 120.0, 'low': 100.0, 'close': 115.0, 'volume': 10000.0}, {'date': '2023-01-03', 'open': 165.0, 'high': 180.0, 'low': 150.0, 'close': 172.5, 'volume': 15000.0}, {'date': '2023-01-04', 'open': 146.67, 'high': 160.0, 'low': 133.33, 'close': 153.33, 'volume': 13333.33}, {'date': '2023-01-05', 'open': 137.5, 'high': 150.0, 'low': 125.0, 'close': 143.75, 'volume': 12500.0}, {'date': '2023-01-06', 'open': 132.0, 'high': 144.0, 'low': 120.0, 'close': 138.0, 'volume': 12000.0}])

Parameters​

data: Data | DataFrame | Series | dict | list | list[DataFrame] | list[Data] | list[Series] | ndarray
Input dataset.

column: str
Column to test for a unit root.

regression: str
Default: c
Deterministic terms: 'c' constant, 'ct' constant and trend, 'ctt' constant, trend, and quadratic trend.

maxlag: int
Maximum lag to include. If None, a data-dependent default is used.

autolag: str
Default: AIC
Lag-selection method: 'AIC', 'BIC', or 't-stat'; None uses maxlag directly without selection.


Returns​

results: UnitRootData

Serializable results.

provider: str

Provider name.

warnings: Optional[list[Warning_]]

List of warnings.

chart: Optional[Chart]

Chart object.

extra: dict[str, Any]

Extra info.


Data​

adf_stat: float
Test statistic (more negative favours stationarity).

p_value: float
MacKinnon p-value.

used_lag: int
Number of lags used.

nobs: int
Number of observations used.

ic_best: float
Maximised information criterion (None when autolag is disabled).

critical_values: dict
Critical values at the 1%, 5%, and 10% levels.