CUSUM of Squares Test

The CUSUM of Squares Test (Brown, Durbin and Evans, 1975) asks whether the variance, not the mean, stayed stable: the cumulative sum of the squared recursive residuals grows in a straight line when the variance is constant and bends away from it when the variance changes. Brown, Durbin and Evans scale the deviation from that line for normal errors; for fat-tailed returns that version rejects far too often, and the scaling of Sansó, Aragó and Carrion (2004) by the variance of the squared residuals keeps it valid.

The formula for the CUSUM of Squares Test starts from the recursive residual \(w_{t}\) of every return \(r_{t}\) from the second on: its distance from M(t-1), the mean of the t - 1 returns before it, scaled by the standard error of that forecast, which leaves \(m = n - 1\) residuals:

\[w_{t} = \frac{r_{t} - M_{t-1}}{\sqrt{1 + \frac{1}{t - 1}}}\]

The variance of the squared residuals, hat(eta)^2, sets the scale:

\[\hat{\eta}^{2} = \frac{\sum_{t=2}^{n} w_{t}^{4}}{m} - \left(\frac{\sum_{t=2}^{n} w_{t}^{2}}{m}\right)^{2}\]

The statistic is the largest distance between the cumulative sum of the squared residuals up to the j-th residual and the straight line j / m of their total:

\[\text{CUSUM}_{\text{Sq}} = \frac{\max\left(\left\lvert \sum_{i=2}^{j + 1} w_{i}^{2} - \left(\frac{j}{m}\right) \cdot \sum_{i=2}^{n} w_{i}^{2}\right\rvert\right)}{\sqrt{m \cdot \hat{\eta}^{2}}}\]

Under a constant variance the scaled path behaves like a Brownian bridge, and the p-value is the probability that the largest absolute value of a Brownian bridge exceeds the statistic:

\[\text{P Value} = 2 \cdot \sum_{k=1}^{\infty} (-1)^{k - 1} \cdot \exp\left(-2 \cdot k^{2} \cdot \text{CUSUM}_{\text{Sq}}^{2}\right)\]

A p-value below the significance level rejects a constant variance, and the date of the largest distance points to where it changed. The scaling allows for fat tails but not for volatility clustering, which can still make the test reject more often than the significance level says.

A CUSUM test asks whether a series stayed stable over time: the null hypothesis is that its mean (or its variance) did not change over the sample, the alternative that it changed at some date that is not known in advance. A test at a given date, such as the Chow test, needs that date; a CUSUM test cumulates the deviations from the stable model instead, and a break makes the cumulative sum drift away from where it would stay without one. A break in the mean return, from a change of regime, a merger or a new policy, makes any model fitted over the whole sample describe neither part well.

Also known as: CUSUMSQ, CUSUM of squares, variance break test.

In the Finance Toolkit this is get_cusum_test with method="cusum_of_squares", the same function as CUSUM Test.

Example · BA, AIR.PA · 2021 to 2025

Install the Finance Toolkit with pip install financetoolkit -U, then call get_cusum_test:

from financetoolkit import Toolkit

toolkit = Toolkit(
    ["BA", "AIR.PA"],
    api_key="FINANCIAL_MODELING_PREP_KEY",
    start_date="2021-01-01",
    end_date="2025-12-31",
)

# The critical values are the asymptotic Brownian Bridge boundaries, so they
# are the same constants for every asset.
toolkit.econometrics.get_cusum_test(method="cusum_of_squares")

Which returns:

Using Your Own Data

get_cusum_test runs on any data, not only prices: ratios, economic indicators, yield curves or your own dataset. Pass a DataFrame, a Series or a dictionary of them to Econometrics as data, with the dates in the rows or the columns, and set changes to how its changes are calculated: "percentage", "log", "difference" for rates and ratios, or None when the data are changes already. For example, for the monthly unemployment rates of the United States and Germany:

from financetoolkit import Economics, Econometrics

economics = Economics(start_date="2000-01-01")

unemployment = economics.get_unemployment_rate(
    countries=["United States", "Germany"], period="monthly"
)

econometrics = Econometrics(data=unemployment, changes="difference")

econometrics.get_cusum_test()

References

  • Paper Brown, R.L., Durbin, J. and Evans, J.M. (1975). “Techniques for Testing the Constancy of Regression Relationships over Time.” Journal of the Royal Statistical Society, Series B, 37(2), 149-192.
  • Paper Sansó, A., Aragó, V. and Carrion, J.L. (2004). “Testing for Changes in the Unconditional Variance of Financial Time Series.” Revista de Economía Financiera, 4, 32-53.
Share