BreakTest#

class cultivars.diagnostics.breaks.BreakTest(*, statistic, pvalue, name, critical_values, null, nobs, lower_tail=False, companions=(), break_index, n_restrictions, trimming, path=None, bounds=None)[source]#

Verdict of a test for one structural break at an unknown date.

Two families share this record. Andrews’ (1993) sup-Wald and Andrews and Ploberger’s (1994) exp- and ave-Wald compute the Wald statistic \(W(\pi)\) for a split at every fraction \(\pi\) of the trimmed window \([\pi_0, 1 - \pi_0]\) and take a functional of the path,

\[\sup_{\pi} W(\pi), \qquad \log \int \exp\bigl(W(\pi) / 2\bigr)\, d\pi, \qquad \int W(\pi)\, d\pi,\]

whose common limit is the same functional of \(BB_q(\pi)^\top BB_q(\pi) / (\pi (1 - \pi))\) with \(BB_q\) a \(q\)-dimensional Brownian bridge. The p-values and critical values are that limit simulated at the trimming actually used, so they are exact for the window rather than read from a table computed at another one. The CUSUM tests of Brown, Durbin and Evans (1975) instead cumulate the recursive residuals and compare the path with a boundary; the record carries the path and the boundary at the three tabulated levels so the crossing can be seen, and the CUSUM proper carries no p-value, only the boundary multipliers, while the CUSUM of squares has its finite-sample boundary simulated and so has one. Rejection always lies in the upper tail.

Variables:
  • break_index – First observation of the new regime at the sup, or the first boundary crossing; None when nothing is located.

  • n_restrictions – Coefficients allowed to change, q.

  • trimming – Fraction of the sample excluded at each end, or None for a boundary test.

  • path – The statistic path over candidate dates, or the CUSUM path.

  • bounds – The boundary at the tabulated levels, (3, n), for a CUSUM test; None otherwise.

Note

For the sup-Wald break_index is the arg-max of the Wald path whether or not the null is rejected: the date is where a break would be, and the verdict says whether one is. For a CUSUM test it is the first date the path leaves the 5% boundary, and None when the path stays inside. The exp- and ave-Wald companions locate nothing and carry no path; they are functionals of the whole window.

See also

  • sup_wald() – the Andrews family, returning this record with the exp- and ave-Wald as companions.

  • cusum() – the Brown-Durbin-Evans family, returning this record with path and bounds.

  • MultipleBreakTest – the Bai-Perron record for more than one break.

  • TabulatedTest – the base that reads a statistic against tabulated critical values.

References

Andrews, D. W. K. (1993). Tests for parameter instability and structural change with unknown change point. Econometrica, 61(4), 821-856.

Andrews, D. W. K., & Ploberger, W. (1994). Optimal tests when a nuisance parameter is present only under the alternative. Econometrica, 62(6), 1383-1414.

Brown, R. L., Durbin, J., & Evans, J. M. (1975). Techniques for testing the constancy of regression relationships over time. Journal of the Royal Statistical Society B, 37(2), 149-192.

Example

A mean shift at observation 100 is found by the sup-Wald at the right date, and the companions agree:

>>> import numpy as np
>>> rng = np.random.default_rng(0)
>>> y = np.concatenate([rng.standard_normal(100), 2.0 + rng.standard_normal(100)])
>>> test = sup_wald(y, seed=0)
>>> test
BreakTest(name='sup-Wald', statistic=187.9089, pvalue=0, break_index=100, nobs=200)
>>> [c.name for c in test.companions], test.n_restrictions, test.trimming
(['exp-Wald', 'ave-Wald'], 1, 0.15)
>>> test.path.shape, int(np.isnan(test.path).sum())
((200,), 59)

The CUSUM carries no p-value, so its verdict comes from the boundary, and only at a tabulated level:

>>> test = cusum(y)
>>> test.pvalue, test.break_index, test.bounds.shape
(None, 116, (3, 199))
>>> test.reject(alpha=0.05)
True
>>> test.reject(alpha=0.03)
Traceback (most recent call last):
    ...
cultivars.exceptions.SpecificationError: CUSUM carries no p-value; ...

Attributes#

break_index

First observation of the new regime, or None when nothing is located.

n_restrictions

Coefficients allowed to change across the break, \(q\).

trimming

Fraction of the sample excluded at each end, or None for a boundary test.

path

The statistic path, (T,) for the sup-Wald or (T - q,) for a CUSUM test.

bounds

The boundary at the 1%, 5%, and 10% levels, (3, T - q), for a CUSUM test.

companions

critical_values

lower_tail

name

nobs

null

pvalue

statistic

Methods#

reject(*[, alpha])

Whether the null is rejected at level alpha.

summary()

The test as a table, renderable as text, HTML, or a dataframe.