Learn R Programming

robcp (version 0.3.8)

hl_test: Hodges-Lehmann Test for Change Points

Description

Performs the two-sample Hodges-Lehmann change point test.

Usage

hl_test(x, b_u = "nrd0", method = "kernel", control = list(), tol = 1e-8, 
        plot = FALSE)

Value

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

Arguments

x

time series (numeric or ts vector).

b_u

bandwidth for u_hat. Either a numeric value or the name of a bandwidth selection function (c.f. bw.nrd0).

method

method for estimating the long run variance.

control

a list of control parameters (cf. lrv).

tol

tolerance of the distribution function (numeric), which is used to compute p-values.

plot

should the test statistic be plotted (cf. plot.cpStat)? Boolean.

Author

Sheila Görz

Details

The function performs the two-sample Hodges-Lehmann change point test. It tests the hypothesis pair $$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. \(k\) is called a 'change point'.

The test statistic is computed using HodgesLehmann and asymptotically follows a Kolmogorov distribution. To derive the p-value, the function pKSdist is used.

References

Dehling, H., Fried, R., and Wendler, M. "A robust method for shift detection in time series." Biometrika 107.3 (2020): 647-660.

See Also

HodgesLehmann, medianDiff, lrv, pKSdist

Examples

Run this code
#time series with a structural break at t = 20
Z <- c(rnorm(20, 0), rnorm(20, 2))

hl_test(Z, control = list(overlapping = TRUE, b_n = 5, b_u = 0.05))

Run the code above in your browser using DataLab