mcusum_test: Change Point Test for Regression

View source: R/mcusum_test.R

mcusum_testR Documentation

Change Point Test for Regression

Description

Apply change point test by \insertCiteHorvath_etal_2017;textualfuntimes for detecting at-most-m changes in regression coefficients, where test statistic is a modified cumulative sum (CUSUM), and critical values are obtained with sieve bootstrap \insertCiteLyubchich_etal_2020_changepointsfuntimes.

Usage

mcusum_test(
  e,
  k,
  m = length(k),
  B = 1000,
  shortboot = FALSE,
  ksm = FALSE,
  ksm.arg = list(kernel = "gaussian", bw = "sj"),
  ...
)

Arguments

e

vector of regression residuals (a stationary time series).

k

an integer vector or scalar with hypothesized change point location(s) to test.

m

an integer specifying the maximum number of change points being confirmed as statistically significant (from those specified in k) would be \le m. Thus, m must be in 1,...,k.

B

number of bootstrap simulations to obtain empirical critical values. Default is 1000.

shortboot

if TRUE, then a heuristic is used to perform the test with a reduced number of bootstrap replicates. Specifically, B/4 replicates are used, which may reduce computing time by up to 75% when the number of retained null hypotheses is large. A p-value of 999 is reported whenever a null hypothesis is retained as a result of this mechanism.

ksm

logical value indicating whether a kernel smoothing to innovations in sieve bootstrap shall be applied (default is FALSE, that is, the original estimated innovations are bootstrapped, without the smoothing).

ksm.arg

used only if ksm = TRUE. A list of arguments for kernel smoothing to be passed to density function. Default settings specify the use of the Gaussian kernel and the "sj" rule to choose the bandwidth.

...

additional arguments passed to ARest (for example, ar.method).

Details

The sieve bootstrap is applied by approximating regression residuals e with an AR(p) model using function ARest, where the autoregressive coefficients are estimated with ar.method, and order p is selected based on ar.order and BIC settings (see ARest). At the next step, B autoregressive processes are simulated under the null hypothesis of no change points. The distribution of test statistics M_T computed on each of those bootstrapped series is used to obtain bootstrap-based p-values for the test \insertCiteLyubchich_etal_2020_changepointsfuntimes.

In the current implementation, the bootstrapped p-value is calculated using equation 4.10 of \insertCiteDavison_Hinkley_1997;textualfuntimes: p.value = (1 + n) / (B + 1), where n is number of bootstrapped statistics greater or equal to the observed statistic.

The test statistic corresponds to the maximal value of the modified CUSUM over up to m combinations of hypothesized change points specified in k. The change points that correspond to that maximum are reported in estimate$khat, and their number is reported as the parameter.

Value

A list of class "htest" containing the following components:

method

name of the method.

data.name

name of the data.

statistic

obseved value of the test statistic.

parameter

mhat is the final number of change points, from those specified in the input k, for which the test statistic is reported. See the corresponding locations, khat, in the estimate.

p.value

bootstrapped p-value of the test.

alternative

alternative hypothesis.

estimate

list with elements: AR_order and AR_coefficients (the autoregressive order and estimated autoregressive coefficients used in sieve bootstrap procedure), khat (final change points, from those specified in the input k for which the test statistic is reported), and B (the number of bootstrap replications).

Author(s)

Vyacheslav Lyubchich

References

\insertAllCited

Examples

##### Model 1 with normal errors, by Horvath et al. (2017)
T <- 100 #length of time series
X <- rnorm(T, mean = 1, sd = 1)
E <- rnorm(T, mean = 0, sd = 1)
SizeOfChange <- 1
TimeOfChange <- 50
Y <- c(1 * X[1:TimeOfChange] + E[1:TimeOfChange],
      (1 + SizeOfChange)*X[(TimeOfChange + 1):T] + E[(TimeOfChange + 1):T])
ehat <- lm(Y ~ X)$resid
mcusum_test(ehat, k = c(30, 50, 70))

#Same, but with bootstrapped innovations obtained from a kernel smoothed distribution:
mcusum_test(ehat, k = c(30, 50, 70), ksm = TRUE)


funtimes documentation built on March 31, 2023, 7:35 p.m.