Utilities for projected-ecdf statistics of spherical uniformity
Utilities for projected-ecdf statistics of spherical uniformity
Computation of the kernels [REMOVE_ME]ψpW(θ):=∫−11Ax(θ)dW(Fp(x)),ψpW(θ):=∫−11Ax(θ)dW(Fp(x)),[REMOVEME2]
where Ax(θ) is the proportion of area surface of Sp−1 covered by the intersection of two hyperspherical caps with common solid angle π−cos−1(x) and centers separated by an angle θ∈[0,π], Fp is the distribution function of the projected spherical uniform distribution , and W is a measure on [0,1].
Also, computation of the Gegenbauer coefficients of ψpW: [REMOVE_ME]bk,pW:=ck,p1∫0πψpW(θ)Ckp/2−1(cosθ)dθ.bk,pW:=ck,p1∫0πψpW(θ)Ck(p/2−1)(cosθ)dθ.[REMOVEME2]
These coefficients can also be computed via [REMOVE_ME]bk,pW=∫−11ak,pxdW(Fp(x))bk,pW=∫−11ak,pxdW(Fp(x))[REMOVEME2]
for a certain function x→ak,px. They serve to define projected alternatives to uniformity .
psi_Pn(theta, q, type, Rothman_t =1/3, tilde =FALSE, psi_Gauss =TRUE, psi_N =320, tol =1e-06)Gegen_coefs_Pn(k, p, type, Rothman_t =1/3, Gauss =TRUE, N =320, tol =1e-06, verbose =FALSE)akx(x, p, k, sqr =FALSE)f_locdev_Pn(p, type, K =1000, N =320, K_max =10000, thre =0.001, Rothman_t =1/3, verbose =FALSE)
Arguments
theta: vector with values in [0,π].
q: integer giving the dimension of the sphere Sq.
type: type of projected-ecdf test statistic. Must be either "PCvM" (Cramér--von Mises), "PAD" (Anderson--Darling), or "PRt" (Rothman).
Rothman_t: t parameter for the Rothman test, a real in (0,1). Defaults to 1 / 3.
tilde: include the constant and bias term? Defaults to FALSE.
psi_Gauss: use a Gauss-Legendre quadrature
rule with psi_N nodes in the computation of the kernel function? Defaults to TRUE.
psi_N: number of points used in the Gauss--Legendre quadrature for computing the kernel function. Defaults to 320.
tol: tolerance passed to integrate's rel.tol and abs.tol if Gauss = FALSE. Defaults to 1e-6.
k: vector with the index of coefficients.
p: integer giving the dimension of the ambient space Rp that contains Sp−1.
Gauss: use a Gauss--Legendre quadrature rule of N nodes in the computation of the Gegenbauer coefficients? Otherwise, call integrate. Defaults to TRUE.
N: number of points used in the Gauss-Legendre quadrature for computing the Gegenbauer coefficients. Defaults to 320.
verbose: flag to print informative messages. Defaults to FALSE.
x: evaluation points for ak,px, a vector with values in [−1,1].
sqr: return the signed square root of ak,px? Defaults to FALSE.
K: number of equispaced points on [−1,1] used for evaluating f and then interpolating. Defaults to 1e3.
K_max: integer giving the truncation of the series. Defaults to 1e4.
thre: proportion of norm not explained by the first terms of the truncated series. Defaults to 1e-3.
Returns
psi_Pn: a vector of size length(theta) with the evaluation of ψ.
Gegen_coefs_Pn: a vector of size length(k) containing the coefficients bk,pW.
akx: a matrix of size c(length(x), length(k))
containing the coefficients ak,px.
f_locdev_Pn: the projected alternative f as a function ready to be evaluated.
where Ax(θ) is the proportion of area surface of Sp−1 covered by the intersection of two hyperspherical caps with common solid angle π−cos−1(x) and centers separated by an angle θ∈[0,π], Fp is the distribution function of the projected spherical uniform distribution , and W is a measure on [0,1].
Also, computation of the Gegenbauer coefficients of ψpW:
for a certain function x→ak,px. They serve to define projected alternatives to uniformity .
Details
The evaluation of ψpW and bk,pW depends on the type of projected-ecdf statistic:
PCvM: closed-form expressions for ψpW and bk,pW
with p=2,3,4, numerical integration required for p≥5.
PAD: closed-form expressions for ψ2W and bk,3W, numerical integration required for ψpW with p≥3 and bk,pW with p=2 and p≥4.
PRt: closed-form expressions for ψpW and bk,pW
for any p≥2.
See García-Portugués et al. (2023) for more details.
Examples
# Kernels in the projected-ecdf test statisticsk <-0:10coefs <- list()(coefs$PCvM <- t(sapply(2:5,function(p) Gegen_coefs_Pn(k = k, p = p, type ="PCvM"))))(coefs$PAD <- t(sapply(2:5,function(p) Gegen_coefs_Pn(k = k, p = p, type ="PAD"))))(coefs$PRt <- t(sapply(2:5,function(p) Gegen_coefs_Pn(k = k, p = p, type ="PRt"))))# Gegenbauer expansionth <- seq(0, pi, length.out =501)[-501]old_par <- par(mfrow = c(3,4))for(type in c("PCvM","PAD","PRt")){for(p in2:5){ plot(th, psi_Pn(theta = th, q = p -1, type = type), type ="l", main = paste0(type,", p = ", p), xlab = expression(theta), ylab = expression(psi(theta)), axes =FALSE, ylim = c(-1.5,1)) axis(1, at = c(0, pi /4, pi /2,3* pi /4, pi), labels = expression(0, pi /4, pi /2,3* pi /4, pi)) axis(2); box() lines(th, Gegen_series(theta = th, coefs = coefs[[type]][p -1,], k = k, p = p), col =2)}}par(old_par)# Analytical coefficients vs. numerical integrationtest_coef <-function(type, p, k =0:20){ plot(k, log1p(abs(Gegen_coefs_Pn(k = k, p = p, type = type))), ylab ="Coefficients", main = paste0(type,", p = ", p)) points(k, log1p(abs(Gegen_coefs(k = k, p = p, psi = psi_Pn, type = type, q = p -1))), col =2) legend("topright", legend = c("log(1 + Gegen_coefs_Pn))","log(1 + Gegen_coefs(psi_Pn))"), lwd =2, col =1:2)}# PCvM statisticold_par <- par(mfrow = c(2,2))for(p in2:5) test_coef(type ="PCvM", p = p)par(old_par)# PAD statisticold_par <- par(mfrow = c(2,2))for(p in2:5) test_coef(type ="PAD", p = p)par(old_par)# PRt statisticold_par <- par(mfrow = c(2,2))for(p in2:5) test_coef(type ="PRt", p = p)par(old_par)# akxakx(x = seq(-1,1, l =5), k =1:4, p =2)akx(x =0, k =1:4, p =3)# PRt alternative to uniformityz <- seq(-1,1, l =1e3)p <- c(2:5,10,15,17)col <- viridisLite::viridis(length(p))plot(z, f_locdev_Pn(p = p[1], type ="PRt")(z), type ="s", col = col[1], ylim = c(0,0.6), ylab = expression(f[Rt](z)))for(k in2:length(p)){ lines(z, f_locdev_Pn(p = p[k], type ="PRt")(z), type ="s", col = col[k])}legend("topleft", legend = paste("p =", p), col = col, lwd =2)
References
García-Portugués, E., Navarro-Esteban, P., Cuesta-Albertos, J. A. (2023) On a projection-based class of uniformity tests on the hypersphere. Bernoulli, 29(1):181--204. tools:::Rd_expr_doi("10.3150/21-BEJ1454") .
Author(s)
Eduardo García-Portugués and Paula Navarro-Esteban.