I’ve got a question concerning the R package strucchange that I use for testing and dating structural breaks in my PhD thesis. To be specific, I use the generalized fluctuation test framework with CUSUM/MOSUM and in particular Moving Estimates (ME) tests for my analysis. Thus, the following description focuses on the ME test, but in principle is more general to all fluctuation tests.

The problem: I am testing time series data for structural breaks with the ME test that draws on the function efp provided by strucchange. Given the nature of time series data, I want to tackle potential heteroskedasticity and autocorrelation in the data. Strucchange provides some functionality with respect to calculating heteroskedasticity (HC) and autocorrelation (HAC) consistent covariance matrices, e.g., the approaches suggested by Newey-West (1987) or Andrews (1991).

However, this functionality in strucchange is limited to the function gefp that calculates Generalized Empirical M-Fluctuation Processes that as far as I know does not allow to perform estimates-based tests such as the ME test. Thus, I cannot use efp to estimate ME tests (or other tests that are available in this function) using HAC covariance matrices.

The question: Does anybody know how I could make use of the efp function in strucchange for testing and dating structural changes but use HAC covariance matrices to take heteroskedasticity and autocorrelation into account? Maybe there is some way to use the sandwich package for this?

Many thanks for any help!

Here is a minimal working example to show the problem



#using the function efp to perform a moving estimates test
#assuming sperical disturbances
ocus.nile <- efp(Nile ~ 1, type = "ME")

#applying the vcov function with the kernHAC option to take heteroskedasticity and autocorrelation does not work, i.e., the option is not used and the result is the same
sctest(ocus.nile, vcov=kernHAC)

#using the function gefp to perform a generalized M-fluctuation process however works with vcov
#assuming spherical disturbances
ocus.nile2 <- gefp(Nile ~ 1, fit = lm)

#controlling for heteroskedasticity and autocorrelation using an appropriate covariance matrix changes the result, i.e. works
ocus.nile2 <- gefp(Nile ~ 1, fit = lm, vcov= kernHAC)

Some background

Though probably not necessary, here is some more in-depth background about the problem for the interested reader (and the archive). The formulas are taken from Zeileis et al., 2005, ”Monitoring structural change in dynamic econometric models”.

The ME test is used to detect structural breaks in the standard linear regression model over time. What it does it in essence partitioning the data and rather than estimating the regression based on the whole sample, it sequentially moves “through” time in a fixed-width windows containing only a sub-sample of the observations and in each window it estimates the model. These estimates are used to the computation of empirical fluctuation processes that capture fluctuations in regression coefficients and residuals over time. Significant fluctuations of the coefficients are signs of a structural break in the regression. The test statistic of the Moving estimates test is

Moving estimates test statistic

where n is the number of observations, h is the bandwith (how many percent of the total number of observations are used for the window), nh is thus the size of the window, Q_(n)=X_(n)^T X_(N)/n, i=[k+t(n-k)], and sigma^2 is an estimate of the variance. The way I understand the above statistic is that it compares the difference between the sub-sample estimate of beta with the whole sample (the window) estimate and how this difference develops over time. A zero difference would indicate a sub-sample estimate that perfectly equals the whole-sample estimate, which would indicate perfect stability of the coefficient. In my understanding, the efp function in strucchange calculates sigma^2 based on the standard OLS residuals u^ i.e., sigma^2=(1/n-k)∑_(i=1)^n u_i^2 . Thus, in the presence of heteroskedasticity or autocorrelation, the OLS assumption of spherical disturbances will be violated. Thus, ideally, sigma^2 should be estimated based on a HAC covariance matrix to avoid wrong inference.

The question that comes to my mind is whether there is a way to use the ME test based on a HAC estimate. If not, it seems to me that it is limited to spherical disturbances of residuals, which seems to be violated in most applications.


closed as off-topic by gung, Xi'an, Peter Flom Apr 11 '15 at 19:29

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question appears to be off-topic because EITHER it is not about statistics, machine learning, data analysis, data mining, or data visualization, OR it focuses on programming, debugging, or performing routine operations within a statistical computing platform. If the latter, you could try the support links we maintain." – gung, Xi'an, Peter Flom
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    $\begingroup$ If you are open to other approaches, I would try tsoutliers package, as it automatically handles autocorelation via arima framework. $\endgroup$ – forecaster Apr 11 '15 at 13:41
  • $\begingroup$ @Achim Zeileis hopefully will want to look into this $\endgroup$ – Christoph Hanck Apr 11 '15 at 14:13
  • 3
    $\begingroup$ Hmmm, while I was answering the question, the moderators put it on hold (which is probably appropriate but still a nuisance if the maintainer is watching the site anyway...). I'll try to put my answer into a separate comment to have some more characters... $\endgroup$ – Achim Zeileis Apr 11 '15 at 19:39
  • 3
    $\begingroup$ The ME test in strucchange can currently not be combined with HC or HAC covariance estimators. Both, the tests in Fstats() and gefp() allow for it though which encompasses tests based on Wald/F statistics, scores, and OLS residuals. And in case you are regressing only on a constant the MOSUM test based on scores or residuals is equialent to the ME test anyway. If you have regressors, then the tests are not equivalent but I wouldn't expect them to yield drastically different results. That's why I never enhanced the old efp() function to take a meat or vcov argument. $\endgroup$ – Achim Zeileis Apr 11 '15 at 19:43
  • 1
    $\begingroup$ One more remark: If the approaches based on Wald/F statistics, scores, or residuals are all not suitable for some reason, let me know. So far I haven't seen any such case but if there is, I might consider adding the possibility of a vcov argument to efp() for RE and ME tests. $\endgroup$ – Achim Zeileis Apr 13 '15 at 16:50