pKSdist: Asymptotic cumulative distribution for the CUSUM Test...

View source: R/pKSdist.R

pKSdistR Documentation

Asymptotic cumulative distribution for the CUSUM Test statistic

Description

Computes the asymptotic cumulative distribution of the statistic of CUSUM.

Usage

pKSdist(tn, tol = 1e-8)
pBessel(tn, p)

Arguments

tn

vector of test statistics (numeric). For pBessel length of tn has to be 1.

p

dimension of time series (integer). If p is equal to 1 pBessel uses pKSdist to compute the corresponding probability.

tol

tolerance (numeric).

Details

For a single time series, the distribution is the same distribution as in the two sample Kolmogorov Smirnov Test, namely the distribution of the maximal value of the absolute values of a Brownian bridge. It is computated as follows (Durbin, 1973 and van Mulbregt, 2018):

For t_n(x) < 1:

P(t_n(X) ≤ t_n(x)) = \frac{√{2 π}}{t_n(x)} t (1 + t^8(1 + t^{16}(1 + t^{24}(1 + ...))))

up to t^{8 k_{max}}, k_{max} = \lfloor √{2 - \log(tol)}\rfloor, where t = \exp(-π^2 / (8x^2))

else:

P(t_n(X) ≤ t_n(x)) = 2 ∑_{k = 1}^{∞} (-1)^{k - 1} \exp(-2 k^2 x^2)

until |2 (-1)^{k - 1} \exp(-2 k^2 x^2) - 2 (-1)^{(k-1) - 1} \exp(-2 (k-1)^2 x^2)| ≤ tol.

In case of multiple time series, the distribution equals that of the maximum of an p dimensional squared Bessel bridge. It can be computed by (Kiefer, 1959)

P(t_n(X) ≤ t_n(x)) = \frac{4}{ Γ(p / 2) 2^{p / 2} t_n^p } ∑_{i = 1}^{∞} \frac{(γ_{(p - 2)/2, n})^{p - 2} \exp(-(γ_{(p - 2)/2, n})^2 / (2t_n^2))}{J_{p/2}(γ_{(p - 2)/2, n})^2 },

where J_p is the Bessel function of first kind and p-th order, Γ is the gamma function and γ_{p, n} denotes the n-th zero of J_p.

Value

vector of P(t_n(X) ≤ tn[i]).

Author(s)

Sheila Görz, Alexander Dürre

References

Durbin, James. (1973) "Distribution theory for tests based on the sample distribution function." Society for Industrial and Applied Mathematics.

van Mulbregt, P. (2018) "Computing the Cumulative Distribution Function and Quantiles of the limit of the Two-sided Kolmogorov-Smirnov Statistic." arXiv preprint arXiv:1803.00426.

/src/library/stats/src/ks.c rev60573

Kiefer, J. (1959). "K-sample analogues of the Kolmogorov-Smirnov and Cramer-V. Mises tests", The Annals of Mathematical Statistics, 420–447.

See Also

psi, CUSUM, psi_cumsum, huber_cusum

Examples

# single time series
timeSeries <- c(rnorm(20, 0), rnorm(20, 2))
tn <- CUSUM(timeSeries)

pKSdist(tn)

# two time series
timeSeries <- matrix(c(rnorm(20, 0), rnorm(20, 2), rnorm(20, 1), rnorm(20, 3)), 
                     ncol = 2)
tn <- CUSUM(timeSeries)

pBessel(tn, 2)


robcp documentation built on Sept. 16, 2022, 5:05 p.m.

Related to pKSdist in robcp...