fintech-algorithms
Using a coding agent? Give it the skill: npx skills add IslamBaraka90/Fintech-Algorithms-Library What it does →

Zivot-Andrews Break Test

Install and import#

bash
npm install fintech-algorithms
ts
import { zivotAndrews } from "fintech-algorithms/statistical-time-series/diagnostics/zivot-andrews-break-test";

Signature#

zivotAndrews(values, lags, trim, criticalValue)

A unit-root test that allows one structural break at an unknown date, found by searching. Standard ADF frequently reports a unit root when the truth is a stationary series with a single level shift.

Parameters#

NameTypeNotes
valuesnumber[]Observation series in chronological order, oldest first.
lagsnumberLagged differences included.
min: 0 · integer: true
trimnumberFraction of the sample trimmed at each end of the break search; the test is unreliable near the boundaries.
min: 0
criticalValuenumberCritical value for the minimum statistic across candidate break dates.

Returns#

{ method, trim, candidate_start, candidate_end, scan, break_index, statistic, decision, … }

The chosen break date with the full scan across candidates, so a marginal choice between two dates is visible.

Errors#

  • When trim leaves too few candidate break points — throws

Complexity: time O(n² × lags), space O(n).

Worked example#

executed Captured by running this function on the input its own test provides. Real output of real code — but not asserted against a published figure.

Input#

values
[10.34556492, 11.02095, 9.20624589, 10.31211299, 10.28712609, 9.63521836]

Showing 6 of 96 elements.

lags
1
trim
0.15
criticalValue
-4.8

Call#

zivotAndrews(values, lags, trim, criticalValue)

Returns#

object with 17 fields: method, variant, nobs, lags, trim, candidate_start, candidate_end, scan, …

{
  "method": "zivot_andrews",
  "variant": "intercept-break-fixed-lag",
  "nobs": 96,
  "lags": 1,
  "trim": 0.15,
  "candidate_start": 15,
  "candidate_end": 80,
  "scan": [
    {
      "break_index": 15,
      "statistic": -2.5968971047294005,
      "gamma": -0.16587948752228582,
      "gamma_standard_error": 0.06387603390992676,
      "level_shift": -0.04138705771243637,
      "residual_sse": 63.10830583976075
    },
    {
      "break_index": 16,
      "statistic": -2.5793149673915057,
      "gamma": -0.16477543600586345,
      "gamma_standard_error": 0.06388341016471631,
      "level_shift": -0.01654423349541098,
      "residual_sse": 63.11836401077814
    },
    {
      "break_index": 17,
      "statistic": -2.570119387857429,
      "gamma": -0.16400056863572565,
      "gamma_standard_error": 0.0638104865519279,
      "level_shift": 0.0005933378039946896,
      "residual_sse": 63.12032010539862
    }
  ],
  "break_index": 47,
  "statistic": -7.029594549659584,
  "gamma": -0.5990847849626595,
  "gamma_standard_error": 0.08522323453088355,
  "level_shift": 3.0605819661853846,
  "critical_value": -4.8
}

Showing 14 of 17 fields.

Other exports#

This module also exports acf, pacf, adf, kpss, ljungBox, runDiagnostic. Every module additionally exports run as an alias of its primary function, and a meta object carrying its catalog id, domain, family, shape and article URL.

Diagrams#

Zivot-Andrews Break Test — diagnostic anatomy

Calculation flow#

Zivot-Andrews Break Test decision flow
flowchart TD
  A["Ordered finite series"] --> B{"Contract valid?"}
  B -- "No" --> X["Stop: explicit invalid state"]
  B -- "Yes" --> C["Apply trim and enumerate break dates"]
  C --> D["Fit fixed-lag intercept-break OLS at each date"]
  D --> E["Select minimum lagged-level t-ratio"]
  E --> F["Compare selected statistic with boundary"]
  F --> G{"Declared strict decision rule"}
  G --> H["Report machine state, null, and limitation"]
  H --> I["Compare with AutoReg"]

How it works#

This page states the contract — how to call it correctly. The article explains the concept: why it works, and where it breaks.

Read the article →

References#

  • Further Evidence on the Great Crash, the Oil-Price Shock, and the Unit-Root Hypothesis
  • statsmodels.tsa.stattools.zivot_andrews
  • Evidence decisions

The rest of the Diagnostics family#