Calculate the Zivot-Andrews test for a unit root, per asset, allowing for a single structural break at an unknown (endogenously estimated) date.

The (A)DF/KPSS/PP tests above all assume the deterministic component of the series (its constant and/or trend) is stable throughout the sample. If a series instead has a single one-time break – e.g. a permanent level shift or a change in trend slope, such as a stock split, spin-off, or a structural shift in the business – the ordinary ADF test is biased towards not rejecting the unit root even for a genuinely (trend-)stationary series with a break. The Zivot-Andrews test corrects for this by adding a break dummy to the ADF regression and choosing, for each asset, the break date that is most favorable to the stationary alternative – which is why it needs its own (more negative) critical values rather than the ordinary ADF ones.

For more information about the method, see the following papers:

  • Zivot, E., & Andrews, D.W.K. (1992). “Further Evidence on the Great Crash, the Oil-Price Shock, and the Unit-Root Hypothesis.” Journal of Business & Economic Statistics, 10(3), 251-270.
  • Perron, P. (1989). “The Great Crash, the Oil Price Shock, and the Unit Root Hypothesis.” Econometrica, 57(6), 1361-1401.

Also known as: ZA test, structural break unit root test.

No programming experience? With the Finance Toolkit MCP server, AI assistants such as Claude and ChatGPT can calculate the Zivot-Andrews Test for you. Just ask in plain English.

Calculate the Zivot-Andrews Test in Python

The Zivot-Andrews Test is available in the Econometrics module of the open-source Finance Toolkit. Install it with:

pip install financetoolkit -U

Then call get_zivot_andrews_test as shown below.

from financetoolkit import Toolkit

toolkit = Toolkit(
    ["AAPL", "MSFT"],
    api_key="FINANCIAL_MODELING_PREP_KEY",
    start_date="2019-01-01",
    end_date="2023-12-31",
)

toolkit.econometrics.get_zivot_andrews_test(period="weekly")

Which returns:

  AAPL MSFT
Zivot-Andrews Statistic -4.7109 -4.4313
P-Value 0.0686 0.1414
Break Index 169 169
Observations 261 261
Lags Used 0 0
Critical Value 1% -5.2764 -5.2764
Critical Value 5% -4.8107 -4.8107
Critical Value 10% -4.5662 -4.5662
Reject Unit Root (5%) 0 0

Parameters

get_zivot_andrews_test accepts the following parameters:

  • period (str, optional): The data frequency (daily, weekly, monthly, quarterly, or yearly). Defaults to “daily”.
  • column (str, optional): The historical data column to test. Defaults to “Adj Close”.
  • max_lag (int, optional): The maximum number of lagged differences to consider when selecting the (single, reused) lag length. Defaults to the Schwert (1989) rule of thumb.
  • regression (str, optional): Which break to allow for, one of “c” (a break in the level/intercept), “t” (a break in the trend slope) or “ct” (both). Defaults to “c”.
  • trim (float, optional): The fraction of observations excluded from the candidate break date search at the start and end of the sample. Must be in [0, 1/3). Defaults to 0.15.
  • include_benchmark (bool, optional): Whether to include “Benchmark” among the assets tested. Defaults to False.
  • rounding (int | None, optional): The number of decimals to round the results to. Defaults to None.

The Econometrics module page introduces the module, and the sidebar lists all of its functions.

Share