View source: R/Hodges_Lehmann.R
HodgesLehmann | R Documentation |
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")
x |
time series (numeric or |
b_u |
bandwidth for |
method |
method of long run variance estimation. Options are |
control |
a list of control parameters for the estimation of the long run variance (cf. |
Let n be the length of the time series. The Hodges-Lehmann test statistic is then computed as
\frac{√{n}}{\hat{σ}_n} \max_{1 ≤q k < n} \hat{u}_{k,n}(0) \frac{k}{n} ≤ft(1 - \frac{k}{n}\right) | med\{(x_j - x_i); 1 ≤q i ≤q k; k+1 ≤q j ≤q n\} | ,
where \hat{σ} 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 (ρ) is computed. Then the default block length follows as
l = \max≤ft\{≤ft\lceil n^{1/3} ≤ft( \frac{2ρ}{1 - ρ^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 ≤q i ≤q k; k+1 ≤q j ≤q 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 ≤q i < j ≤q n}.
HodgesLehmann
returns a test statistic (numeric value) with the following attributes:
cp-location |
indicating at which index a change point is most likely. |
teststat |
test process (before taking the maximum). |
lrv-estimation |
long run variance estimation method. |
sigma |
estimated long run variance. |
param |
parameter used for the lrv estimation. |
kFun |
kernel function used for the lrv estimation. |
Is an S3 object of the class "cpStat".
u_hat
returns a numeric value.
Sheila Görz
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.