Skip to main content

unit_root

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

The ADF test is a popular method for testing the presence of a unit root in a time series. A unit root indicates that the series may be non-stationary, meaning its statistical properties such as mean, variance, and autocorrelation can change over time. The presence of a unit root suggests that the time series might be influenced by a random walk process, making it unpredictable and challenging for modeling and forecasting. The 'regression' parameter allows you to specify the model used in the test: 'c' for a constant term, 'ct' for a constant and trend term, and 'ctt' for a constant, linear, and quadratic trend. This flexibility helps tailor the test to the specific characteristics of your data, providing a more accurate assessment of its stationarity.

Examples

from openbb import obb
# Perform Augmented Dickey-Fuller (ADF) unit root test.
stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp').to_df()
obb.econometrics.unit_root(data=stock_data, column="close")
obb.econometrics.unit_root(data=stock_data, column="close", regression="ct")
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: list[openbb_core.provider.abstract.data.Data]

Input dataset.

Optional: False


column: str

Data columns to check unit root

Optional: False


regression: Literal['c', 'ct', 'ctt']

Regression type to use in the test. Either 'c' for constant only, 'ct' for constant and trend, or 'ctt' for

Default: c

Optional: True


Returns

results: list[Data]

Serializable results.


provider: None

Provider name.


warnings: Optional[list[Warning_]]

list of warnings.


chart: Optional[Chart]

Chart object.


extra: dict[str, Any]

Extra info.