cultivars.diagnostics.breaks#

Structural-break tests: whether one regression held over the whole sample.

A break at a known date is a Chow test and needs nothing here. The tests in this module are for the case that matters in practice, a break at a date the data must locate, where the break date is a nuisance parameter present only under the alternative and the usual chi-squared limit does not apply. sup_wald() scans the trimmed window \([\pi_0 T, (1 - \pi_0) T]\), computes at each candidate date the Wald statistic for equality of the coefficients on either side, and reports the largest (Andrews 1993) together with the exponential and average functionals of Andrews and Ploberger (1994), all three of which converge under the null to functionals of

\[\frac{BB_q(\pi)^\top BB_q(\pi)}{\pi (1 - \pi)}, \qquad \pi \in [\pi_0, 1 - \pi_0],\]

with \(BB_q\) a \(q\)-dimensional Brownian bridge. That limit is simulated here at the trimming actually used, so the p-values are the asymptotic ones for the window rather than an interpolation of a printed table. bai_perron() extends the search to several breaks with the dynamic-programming global minimizer of Bai and Perron (2003), which tables the residual sum of every admissible segment once and finds the best partition for each count from that table; it selects the number of breaks by BIC, by the Liu-Wu-Zidek criterion, or by the sequential \(\sup F(l + 1 \mid l)\) procedure whose p-values follow from the single-break limit as \(1 - G(x)^{l + 1}\), and reports every partition considered. cusum() is the recursive-residual diagnostic of Brown, Durbin and Evans (1975): the standardized one-step forecast errors of the regression re-estimated as each observation arrives are cumulated and compared with a boundary, and a path that crosses says the coefficients drifted, without a date to name; the CUSUM of squares does the same for the variance, with its finite-sample boundary simulated exactly.

Two commitments shape the surface. First, the record shows its evidence. A BreakTest carries the Wald path over candidate dates or the CUSUM path with its boundary, and a MultipleBreakTest carries the partition, residual sum, and both criteria for every count together with each sequential test taken, so a verdict can be read against the shape that produced it and a selection against the alternatives it beat. Second, the null distribution is simulated, not tabulated. Every p-value in the module comes from draws of the limit process, or of the exact finite-sample path for the CUSUM of squares, at the trimming and sample size in hand; the one exception is the CUSUM proper, whose boundary multipliers are Brown, Durbin and Evans’ and whose record therefore carries critical values without a p-value.

Each function takes a target and, optionally, regressors; with none, the regression is on the deterministic terms alone, so the test is for a break in the mean or trend. Every coefficient is allowed to break at once, and serially correlated or heteroskedastic errors are not corrected for: include the lags the dynamics call for in exog, or read the result as a diagnostic rather than a test.

Layout. BreakTest is the single-break record, a _TabulatedTest that reads its statistic against simulated or tabulated critical values and carries the path; MultipleBreakTest is the Bai-Perron record with its own summary table over counts. sup_wald(), bai_perron(), and cusum() are the producers. The numerics live in _core: _bridge_functionals simulates the sup, exp, and ave functionals of the Brownian-bridge limit and _simulated_critical_values turns the draws into a p-value and critical values; _segment_ssr tables the segment residual sums and _bai_perron_partition runs the dynamic program over them; _recursive_residuals produces the standardized forecast errors, _cusum_squares_quantiles simulates the finite-sample boundary, and _CUSUM_BOUNDARY holds the tabulated multipliers; _validate_regression assembles the design from the deterministic terms and the regressors.

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.

Bai, J., & Perron, P. (1998). Estimating and testing linear models with multiple structural changes. Econometrica, 66(1), 47-78.

Bai, J., & Perron, P. (2003). Computation and analysis of multiple structural change models. Journal of Applied Econometrics, 18(1), 1-22.

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.

Perron, P. (2006). Dealing with structural breaks. In Palgrave Handbook of Econometrics, Volume 1: Econometric Theory (pp. 278-352). Palgrave Macmillan.

Example

A mean shift at observation 100: the sup-Wald dates it, the Bai-Perron selection counts it, and the CUSUM path crosses its band after it:

>>> 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.reject(), test.break_index
(True, 100)
>>> bai_perron(y, max_breaks=3, seed=0).break_indices
(100,)
>>> cusum(y).reject(alpha=0.05)
True

Classes#

BreakTest

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

MultipleBreakTest

Bai and Perron's (1998, 2003) multiple-break analysis of a linear regression.

Functions#

bai_perron(endog[, exog, trend, max_breaks, ...])

Bai-Perron estimation of multiple breaks in a linear regression.

cusum(endog[, exog, trend, squares, ...])

CUSUM and CUSUM-of-squares tests of coefficient constancy.

sup_wald(endog[, exog, trend, trimming, ...])

Andrews' sup-Wald test for one break at an unknown date, with exp- and ave-Wald.