cor_cusum | R Documentation |
Performs a CUSUM-based test on changes in Spearman's rho or Kendall's tau.
cor_cusum(x, version = c("tau", "rho"), method = "kernel", control = list(), fpc = TRUE, tol = 1e-08, plot = FALSE)
x |
time series (matrix or ts object with numeric/integer values). |
version |
version of the test. Either |
method |
method for estimating the long run variance. |
control |
a list of control parameters. |
fpc |
finite population correction (boolean). |
tol |
tolerance of the distribution function (numeric), which is used do compute p-values. |
plot |
should the test statistic be plotted (cf. |
The function perform a CUSUM-type test on changes in the fluctuation of a time series x. Formally, the hypothesis pair can be written as
H_0: ξ_1, ..., ξ_n
vs.
H_1: \exists k \in \{1, ..., n-1\}: ξ_k \neq ξ_{k+1}
where ξ_i is a fluctuation measure (either Spearman's rho or Kendall's tau) and n is the length of the time series. k is called a 'change point'.
The test statistic is computed using cor_stat
and asymptotically follows a Kolmogorov distribution. To derive the p-value, the funtion pKSdist
is used.
A list of the class "htest" containing the following components:
statistic |
return value of the function |
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). |
lrv |
list containing the compontents |
Sheila Görz
Wied, D., Dehling, H., Van Kampen, M., and Vogel, D. (2014). A fluctuation test for constant Spearman’s rho with nuisance-free limit distribution. Computational Statistics & Data Analysis, 76, 723-736.
Dürre, A. (2022+). "Finite sample correction for cusum tests", unpublished manuscript
cor_stat
, lrv
, pKSdist
### first: gerenate a time series with a burn-in period of m and a change point k require(mvtnorm) n <- 500 m <- 100 N <- n + m k <- m + floor(n * 0.5) n1 <- N - k ## Spearman's rho: rho <- c(0.4, -0.9) # serial dependence: theta1 <- 0.3 theta2 <- 0.2 theta <- cbind(c(theta1, 0), c(0, theta2)) q <- rho * sqrt( (theta1^2 + 1) * (theta2^2 + 1) / (theta1 * theta2 + 1)) # shape matrices of the innovations: S0 <- cbind(c(1, q[1]), c(q[1], 1)) S1 <- cbind(c(1, q[2]), c(q[2], 1)) e0 <- rmvt(k, S0, 5) e1 <- rmvt(n1, S1, 5) e <- rbind(e0, e1) # generate the data: x <- matrix(numeric(N * 2), ncol = 2) x[1, ] <- e[1, ] invisible(sapply(2:N, function(i) x[i, ] <<- e[i, ] + theta %*% e[i-1, ])) x <- x[-(1:m), ] cor_cusum(x, "rho") ## Kendall's tau S0 <- cbind(c(1, rho[1]), c(rho[1], 1)) S1 <- cbind(c(1, rho[2]), c(rho[2], 1)) e0 <- rmvt(k, S0, 5) e1 <- rmvt(n1, S1, 5) e <- rbind(e0, e1) x <- matrix(numeric(N * 2), ncol = 2) x[1, ] <- e[1, ] # AR(1): invisible(sapply(2:N, function(i) x[i, ] <<- 0.8 * x[i-1, ] + e[i, ])) x <- x[-(1:m), ] cor_cusum(x, version = "tau")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.