Computes the test statistic for the Hodges-Lehmann change point test.
HodgesLehmann(x, b_u = "nrd0", method = "kernel", control = list())
u_hat(x, b_u = "nrd0")
HodgesLehmann
returns a test statistic (numeric value) with the following attributes:
indicating at which index a change point is most likely.
test process (before taking the maximum).
long run variance estimation method.
estimated long run variance.
parameter used for the lrv estimation.
kernel function used for the lrv estimation.
Is an S3 object of the class "cpStat".
u_hat
returns a numeric value.
time series (numeric or ts
vector).
bandwidth for u_hat
. Either a numeric value or the name
of a bandwidth selection function (c.f. bw.nrd0
).
method of long run variance estimation. Options are "kernel"
, "subsampling"
, "bootstrap"
and "none"
.
a list of control parameters for the estimation of the long run variance (cf. lrv
).
Sheila Görz
Let \(n\) be the length of the time series. The Hodges-Lehmann test statistic is then computed as
$$\frac{\sqrt{n}}{\hat{\sigma}_n} \max_{1 \leq k < n} \hat{u}_{k,n}(0) \frac{k}{n} \left(1 - \frac{k}{n}\right) | med\{(x_j - x_i); 1 \leq i \leq k; k+1 \leq j \leq n\} | ,$$
where \(\hat{\sigma}\) is the estimated long run variance, computed by the square root of lrv
. By default the long run variance is estimated kernel-based with the following bandwidth: first the time series \(x\) is corrected for the estimated change point and Spearman's autocorrelation to lag 1 (\(\rho\)) is computed. Then the default block length follows as
$$l = \max\left\{\left\lceil n^{1/3} \left( \frac{2\rho}{1 - \rho^2}\right)^{0.9} \right\rceil, 1\right\}.$$
\(\hat{u}_{k,n}(0)\) is estimated by u_hat
on data \(\tilde{x}\), where \(med\{(x_j - x_i); 1 \leq i \leq k; k+1 \leq j \leq n\}\) was subtracted from \(x_{k+1}, ..., x_n\). Then density
with the arguments na.rm = TRUE
, from = 0
, to = 0
, n = 1
and bw = b_u
is applied to \((\tilde{x}_i - \tilde{x_j})_{1 \leq i < j \leq n}\).
Dehling, H., Fried, R., and Wendler, M. "A robust method for shift detection in time series." Biometrika 107.3 (2020): 647-660.
medianDiff
, lrv
# time series with a location change at t = 20
x <- c(rnorm(20, 0), rnorm(20, 2))
# Hodges-Lehmann change point test statistic
HodgesLehmann(x, b_u = 0.01)
Run the code above in your browser using DataLab