Computes the test statistic for a CUSUM-based tests on changes in Spearman's rho or Kendall's tau.
cor_stat(x, version = c("tau", "rho"), method = "kernel", control = list())
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".
time series (numeric or ts vector).
version of the test. Either "rho"
or "tau"
.
methods of long run variance estimation. Options are "kernel"
and "none"
.
a list of control parameters.
Sheila Görz
Let \(n\) be the length of the time series, i.e. the number of rows in x
. In general, the (scaled) CUSUM test statistic is defined as
$$\hat{T}_{\xi; n} = \max_{k = 1, ..., n} \frac{k}{2\sqrt{n}\hat{\sigma}} | \hat{\xi}_k - \hat{\xi}_n |,$$
where \(\hat{\xi}\) is an estimator for the property on which to test, and \(\hat{\sigma}\) is an estimator for the square root of the corresponding long run variance (cf. lrv
).
If version = "tau"
, the function tests if the correlation between \(x_i\) and \(x_i\) of the bivariate time series \((x_i, x_i)_{i = 1, ..., n}\) stays constant for all \(i = 1, ..., n\) by considering Kendall's tau. Therefore, \(\hat{\xi} = \hat{\tau}\) is the the sample version of Kendall's tau:
$$\hat{\tau}_k = \frac{2}{k(k-1)} \sum_{1 \leq i < j \leq k} sign\left((x_j - x_i)(y_j - y_i)\right).$$
The default bandwidth for the kernel-based long run variance estimation is \(b_n = \lfloor 2n^{1/3} \rfloor\) and the default kernel function is the quatratic kernel.
If version = "rho"
, the function tests if the correlation of a time series of an arbitrary dimension \(d\) (>= 2) stays constant by considering a multivariate version of Spearman's rho. Therefore, \(\hat{\xi} = \hat{\rho}\) is the sample version of Spearman's rho:
$$\hat{\rho}_k = a(d) \left( \frac{2^d}{k} \sum_{j = 1}^k \prod_{i = 1}^d (1 - U_{i, j; n}) - 1 \right)$$
where \(U_{i, j; n} = n^{-1}\) (rank of \(x_{i,j}\) in \(x_{i,1}, ..., x_{i,n})\) and \(a(d) = (d+1) / (2^d - d - 1)\). Here it is essential to use \(\hat{U}_{i, j; n}\) instead of \(\hat{U}_{i, j; k}\). The default bandwidth for the kernel-based long run variance estimation is \(\sqrt{n}\) and the default kernel function is the Bartlett kernel.
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.
lrv
, cor_cusum