huber_cusum | R Documentation |
Performs a CUSUM test on data transformed by psi
. Depending on the chosen psi-function different types of changes can be detected.
huber_cusum(x, fun = "HLm", k, constant = 1.4826, method = "kernel",
control = list(), fpc = TRUE, tol = 1e-8, plot = FALSE, ...)
x |
numeric vector containing a single time series or a numeric matrix containing multiple time series (column-wise). |
fun |
character string specifying the transformation function |
k |
numeric bound used in |
constant |
scale factor of the MAD. Default is 1.4826. |
method |
method for estimating the long run variance. |
control |
a list of control parameters for the estimation of the long run variance (cf. |
fpc |
finite population correction (boolean). |
tol |
tolerance of the distribution function (numeric), which is used to compute p-values. |
plot |
should the test statistic be plotted (cf. |
... |
further arguments to be passed to |
The function performs a Huberized CUSUM test. It tests the null hypothesis H_0: \boldsymbol{\theta}
does not change for x
against the alternative of a change, where \boldsymbol{\theta}
is the parameter vector of interest. k
is called a 'change point'. First the data is transformed by a suitable psi-function. To detect changes in location one can apply fun = "HLm"
, "HLg"
, "SLm"
or "SLg"
and the hypothesis pair is
H_0: \mu_1 = ... = \mu_n
vs.
H_1: \exists k \in \{1, ..., n-1\}: \mu_k \neq \mu_{k+1}
where \mu_t = E(X_t)
and n
is the length of the time series. For changes in scale fun = "HCm"
is available and for changes in the dependence respectively covariance structure fun = "HCm"
, "HCg"
, "SCm"
and "SCg"
are possible. The hypothesis pair is the same as in the location case, only with \mu_i
being replaced by \Sigma_i
, \Sigma_i = Cov(X_i)
. Exact definitions of the psi-functions can be found on the help page of psi
.
Denote by Y_1,\ldots,Y_n
the transformed time series. If Y_1
is one-dimensional, then the test statistic
V_n = \max_{k=1,\ldots,n} \frac{1}{\sqrt{n}\sigma} \left|\sum_{i=1}^k Y_i-\frac{k}{n} \sum_{i=1}^n Y_i\right|
is calculated, where \sigma^2
is an estimator for the long run variance, see the help function of lrv
for details. V
is asymptotically Kolmogorov-Smirnov distributed. If fpc
is TRUE
we use a finite population correction V+0.58/\sqrt{n}
to improve finite sample performance (Dürre, 2021+).
If Y_1
is multivariate, then the test statistic
W_n=\max_{k=1,\ldots,n} \frac{1}{n}\left(\sum_{i=1}^k Y_i-\frac{k}{n} \sum_{i=1}^n Y_i\right)' \Sigma^{-1}\left(\sum_{i=1}^k Y_i-\frac{k}{n} \sum_{i=1}^n Y_i\right)
is computed, where \Sigma
is the long run covariance, see also lrv
for details. W
is asymptotically distributed like the maximum of a squared Bessel bridge. We use the identity derived by Kiefer (1959) to derive p-values. Like in the one dimensional case if fpc
is TRUE
we use a finite sample correction (\sqrt{W}+0.58/\sqrt{n})^2
.
The change point location is estimated as the time point k
for which the CUSUM process takes its maximum.
A list of the class "htest" containing the following components:
statistic |
value of the test statistic (numeric). |
p.value |
p-value (numeric). |
alternative |
alternative hypothesis (character string). |
method |
name of the performed test (character string). |
cp.location |
index of the estimated change point location (integer). |
data.name |
name of the data (character string). |
Sheila Görz
Hušková, M., & Marušiaková, M. (2012). M-procedures for detection of changes for dependent observations. Communications in Statistics-Simulation and Computation, 41(7), 1032-1050.
Dürre, A. and Fried, R. (2019). "Robust change point tests by bounded transformations", https://arxiv.org/abs/1905.06201
Dürre, A. (2021+). "Finite sample correction for cusum tests", unpublished manuscript
Kiefer, J. (1959). "K-sample analogues of the Kolmogorov-Smirnov and Cramer-V. Mises tests", The Annals of Mathematical Statistics, 420–447.
lrv
,
psi
, psi_cumsum
, CUSUM
,
pKSdist
set.seed(1895)
#time series with a structural break at t = 20
Z <- c(rnorm(20, 0), rnorm(20, 2))
huber_cusum(Z)
# two time series with a structural break at t = 20
timeSeries <- matrix(c(rnorm(20, 0), rnorm(20, 2), rnorm(20, 1), rnorm(20, 3),
ncol = 2))
huber_cusum(timeSeries)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.