Skip to main content

unitroot_test

Get Unit Root Test.

This function applies two renowned tests to assess whether your data series is stationary or if it contains a unit root, indicating it may be influenced by time-based trends or seasonality. The Augmented Dickey-Fuller (ADF) test helps identify the presence of a unit root, suggesting that the series could be non-stationary and potentially unpredictable over time. On the other hand, the Kwiatkowski-Phillips-Schmidt-Shin (KPSS) test checks for the stationarity of the series, where failing to reject the null hypothesis indicates a stable, stationary series. Together, these tests provide a comprehensive view of your data's time series properties, essential for accurate modeling and forecasting.

Example:​

from openbb import obb
stock_data = obb.equity.price.historical(symbol="TSLA", start_date="2023-01-01", provider="fmp")
obb.quantitative.unitroot_test(data=stock_data, target="close")
obb.quantitative.unitroot_test(data=stock_data, target="close", fuller_reg="ct", kpss_reg="ct")

Parameters​

NameTypeDescriptionDefaultOptional
dataList[Data]Time series data.NoneFalse
targetstrTarget column name.NoneFalse
fuller_regLiteral["c", "ct", "ctt", "nc", "c"]Regression type for ADF test.cTrue
kpss_regLiteral["c", "ct"]Regression type for KPSS test.cTrue

Returns​

Unit root tests summary.