Pn {sphunif} | R Documentation |
Utilities for projected-ecdf statistics of spherical uniformity
Description
Computation of the kernels
where is the proportion of area surface of
covered by the
intersection of two hyperspherical caps with common solid
angle
and centers separated by
an angle
,
is the distribution function
of the projected spherical uniform distribution,
and
is a measure on
.
Also, computation of the Gegenbauer coefficients of
:
These coefficients can also be computed via
for a certain function . They serve to define
projected alternatives to uniformity.
Usage
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 |
q |
integer giving the dimension of the sphere |
type |
type of projected-ecdf test statistic. Must be either
|
Rothman_t |
|
tilde |
include the constant and bias term? Defaults to |
psi_Gauss |
use a Gauss–Legendre quadrature
rule with |
psi_N |
number of points used in the Gauss–Legendre quadrature for
computing the kernel function. Defaults to |
tol |
tolerance passed to |
k |
vector with the index of coefficients. |
p |
integer giving the dimension of the ambient space |
Gauss |
use a Gauss–Legendre quadrature rule of |
N |
number of points used in the
Gauss–Legendre quadrature for computing the Gegenbauer coefficients.
Defaults to |
verbose |
flag to print informative messages. Defaults to |
x |
evaluation points for |
sqr |
return the signed square root of |
K |
number of equispaced points on |
K_max |
integer giving the truncation of the series. Defaults to
|
thre |
proportion of norm not explained by the first terms of the
truncated series. Defaults to |
Details
The evaluation of and
depends on the type of
projected-ecdf statistic:
PCvM: closed-form expressions for
and
with
, numerical integration required for
.
PAD: closed-form expressions for
and
, numerical integration required for
with
and
with
and
.
PRt: closed-form expressions for
and
for any
.
See García-Portugués et al. (2023) for more details.
Value
-
psi_Pn
: a vector of sizelength(theta)
with the evaluation of.
-
Gegen_coefs_Pn
: a vector of sizelength(k)
containing the coefficients.
-
akx
: a matrix of sizec(length(x), length(k))
containing the coefficients.
-
f_locdev_Pn
: the projected alternativeas a function ready to be evaluated.
Author(s)
Eduardo García-Portugués and Paula Navarro-Esteban.
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. doi:10.3150/21-BEJ1454.
Examples
# Kernels in the projected-ecdf test statistics
k <- 0:10
coefs <- 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 expansion
th <- seq(0, pi, length.out = 501)[-501]
old_par <- par(mfrow = c(3, 4))
for (type in c("PCvM", "PAD", "PRt")) {
for (p in 2: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 integration
test_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 statistic
old_par <- par(mfrow = c(2, 2))
for (p in 2:5) test_coef(type = "PCvM", p = p)
par(old_par)
# PAD statistic
old_par <- par(mfrow = c(2, 2))
for (p in 2:5) test_coef(type = "PAD", p = p)
par(old_par)
# PRt statistic
old_par <- par(mfrow = c(2, 2))
for (p in 2:5) test_coef(type = "PRt", p = p)
par(old_par)
# akx
akx(x = seq(-1, 1, l = 5), k = 1:4, p = 2)
akx(x = 0, k = 1:4, p = 3)
# PRt alternative to uniformity
z <- 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 in 2: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)