Recursive CUSUM Test

The Recursive CUSUM Test (Brown, Durbin and Evans, 1975) cumulates the recursive residuals: the one-step-ahead forecast errors of the mean return, each made from the returns before it only. Under a stable mean these errors are independent with a constant variance, so their cumulative sum behaves like a Brownian motion; after a break the errors share a sign and the path drifts out of two lines that widen with time. It reacts to a break late in the sample better than the OLS-CUSUM Test, which compares every return with the mean of the whole sample.

The formula for the Recursive CUSUM 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:

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

The path \(W_{j}\) cumulates the residuals up to date j and divides them by their standard deviation hat(sigma_w) over the n - 1 residuals:

\[\hat{\sigma}_{w}^{2} = \frac{\sum_{t=2}^{n} w_{t}^{2}}{n - 1}\] \[W_{j} = \frac{\sum_{t=2}^{j} w_{t}}{\hat{\sigma}_{w}}\]

The statistic is the largest multiple of the boundary sqrt(n - 1) + 2 * (j - 1) / sqrt(n - 1), two lines that widen with time, that the path reaches:

\[\text{CUSUM}_{\text{Rec}} = \max\left(\frac{\left\lvert W_{j}\right\rvert}{\sqrt{n - 1} + \frac{2 \cdot (j - 1)}{\sqrt{n - 1}}}\right)\]

The p-value is the probability that a Brownian motion crosses the boundary at that multiple, with Phi the standard normal distribution function:

\[\text{P Value} = 2 \cdot \left(1 - \Phi(3 \cdot \text{CUSUM}_{\text{Rec}}) + \exp\left(-4 \cdot \text{CUSUM}_{\text{Rec}}^{2}\right) \cdot \Phi(\text{CUSUM}_{\text{Rec}})\right)\]

A p-value below the significance level rejects a stable mean; so does a statistic above the critical values of Brown, Durbin and Evans (1975), 1.143 at 1%, 0.948 at 5% and 0.850 at 10%. The first recursive residuals rest on few returns, so the path is noisy at the start of the sample.

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: CUSUM of recursive residuals, Brown-Durbin-Evans test, recursive CUSUM test.

In the Finance Toolkit this is get_cusum_test with method="recursive", 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="recursive")

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.
  • Library Shares similar logic as statsmodels’ recursive_olsresiduals (Recursive CUSUM Test)
Share