mcusum_test: Change Point Test for Regression

Description Usage Arguments Details Value Author(s) References Examples

View source: R/mcusum_test.R

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

1
2
3
4
5
6
7
8
mcusum_test(
  e,
  k,
  B = 1000,
  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. The length of this vector is treated as m, that is, the number of change points being confirmed as statistically significant (from those specified in k) would be ≤ m.

B

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

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 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.

The test statistic corresponds to the maximal value of the modified CUSUM over all 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 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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
##### 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 Nov. 28, 2020, 1:06 a.m.