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.

Example​

from openbb import obb

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")

Parameters​

NameTypeDescriptionDefaultOptional
dataList[Data]Input dataset.False
columnstrData columns to check unit rootFalse
regressionLiteral['c', 'ct', 'ctt']Regression type to use in the test. Either "c" for constant only, "ct" for constant and trend, or "ctt" forcFalse

Returns​

OBBject
results : Data
OBBject with the results being the score from the test.