MultipleBreakTest#

class cultivars.diagnostics.breaks.MultipleBreakTest(*, break_indices, n_breaks, criterion, ssr, bic, lwz, partitions, sequential, n_restrictions, trimming, nobs)[source]#

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

For each number of breaks \(m = 0, \ldots, m_{\max}\) the record carries the global least-squares partition, the \(m\) dates \((T_1, \ldots, T_m)\) that minimize the total sum of squared residuals over segments of at least trimming times the sample, found by dynamic programming over a table of segment sums. Three ways of choosing \(m\) are computed on every call and the one asked for is reported. Two are information criteria over the partition sequence, with \(p_m = (m + 1) q + m\) parameters,

\[\mathrm{BIC}(m) = \ln\frac{S_m}{T} + \frac{p_m \ln T}{T}, \qquad \mathrm{LWZ}(m) = \ln\frac{S_m}{T - p_m} + \frac{0.299\, p_m (\ln T)^{2.1}}{T},\]

the second Liu, Wu and Zidek’s (1997) modification that Bai and Perron found less prone to over-fitting. The third is sequential: from \(l\) breaks, the largest single-break sup-F over the current segments tests \(l\) against \(l + 1\), its p-value following from the single-break limit \(G\) as \(1 - G(x)^{l + 1}\), and the procedure stops at the first non-rejection. The sequential tests are kept on the record whichever criterion selected, so the three can be read against each other.

Variables:
  • break_indices – First observation of each new regime under the selected number of breaks.

  • n_breaks – The selected number.

  • criterion – "bic", "lwz" or "sequential".

  • ssr – Sum of squared residuals for 0 .. max_breaks breaks.

  • bic – Bayesian information criterion for each count.

  • lwz – Liu-Wu-Zidek criterion for each count.

  • partitions – The global partition for each count.

  • sequential – The sup F(l + 1 | l) tests, one per step taken.

  • n_restrictions – Regression coefficients, q.

  • trimming – Minimum segment length as a fraction of the sample.

  • nobs – Observations.

Note

The partitions are not nested: the best two-break partition need not contain the best single break, and in the example below it does not. sequential may be shorter than max_breaks, since the procedure stops at the first non-rejection or when no segment is long enough to split; it is computed and kept under the information criteria as well. This record is not a hypothesis test and has no reject; the sequential entries are BreakTest records and do.

See also

  • bai_perron() – the producer.

  • BreakTest – the single-break record, and the type of each entry in sequential.

  • sup_wald() – the single-break test the sequential step applies segment by segment.

References

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.

Liu, J., Wu, S., & Zidek, J. V. (1997). On segmented multivariate regression. Statistica Sinica, 7(2), 497-525.

Example

Two mean shifts, at 100 and 200, in three hundred observations. BIC selects two breaks at the right dates; the third sequential test does not reject, and the single-break partition puts its one date at 200, not inside the two-break partition’s:

>>> import numpy as np
>>> rng = np.random.default_rng(0)
>>> y = np.concatenate([
...     rng.standard_normal(100),
...     2.0 + rng.standard_normal(100),
...     -1.0 + rng.standard_normal(100),
... ])
>>> test = bai_perron(y, max_breaks=3, seed=0)
>>> test
MultipleBreakTest(n_breaks=2, break_indices=(100, 200), criterion='bic', nobs=300)
>>> test.max_breaks, test.partitions
(3, ((), (200,), (100, 200), (100, 145, 200)))
>>> [(t.name, round(t.pvalue, 3)) for t in test.sequential]
[('sup F(1 | 0)', 0.0), ('sup F(2 | 1)', 0.0), ('sup F(3 | 2)', 0.999)]
>>> bai_perron(y, max_breaks=3, criterion="sequential", seed=0).n_breaks
2

Attributes#

break_indices

First observation of each new regime, under the selected number of breaks.

n_breaks

The number of breaks the criterion selected, from 0 to max_breaks.

criterion

"bic", "lwz", or "sequential".

ssr

Sum of squared residuals of the global partition, (max_breaks + 1,).

bic

Bayesian information criterion per count, (max_breaks + 1,).

lwz

Liu-Wu-Zidek criterion per count, (max_breaks + 1,).

partitions

The global least-squares partition for each count, max_breaks + 1 tuples.

sequential

The sup F(l + 1 | l) tests, in order, one per step the procedure took.

n_restrictions

Regression coefficients per segment, \(q\), deterministic terms included.

trimming

Minimum segment length as a fraction of the sample.

nobs

Observations the regression was fitted on.

max_breaks

Largest number of breaks considered.

Methods#

summary()

Render as a table over the number of breaks.