Density and random generation for local projected alternatives to uniformity with densities [REMOVE_ME]fκ,μ(x):=ωp1−κ+κf(x′μ)fκ,μ(x)=(1−κ)/ωp+κf(x′μ)[REMOVEME2]
where [REMOVE_ME]f(z)=ωp1{1+∑k=1∞uk,pCkp/2−1(z)}f(x)=(1/ωp)1+∑k=1∞uk,pCk(p/2−1)(z)[REMOVEME2]
is the angular function controlling the local alternative in a Gegenbauer series , 0≤κ≤1, μ is a direction on Sp−1, and ωp is the surface area of Sp−1. The sequence {uk,p} is typically such that c("\n", "uk,p=(1+2k/(p−2))bk,p") for the Gegenbauer coefficients {bk,p} of the kernel function of a Sobolev statistic (see the transformation between the coefficients uk,p
and bk,p).
Also, automatic truncation of the series ∑k=1∞uk,pCk(p/2−1)(z)
z: projected evaluation points for f, a vector with entries on [−1,1].
p: integer giving the dimension of the ambient space Rp that contains Sp−1.
uk: coefficients uk,p associated to the indexes 1:length(uk), a vector.
f: angular function defined on [−1,1]. Must be vectorized.
N: number of points used in the Gauss-Legendre quadrature for computing the Gegenbauer coefficients. Defaults to 320.
x: locations in Sp−1 to evaluate the density. Either a matrix of size c(nx, p) or a vector of length p. Normalized internally if required (with a warning message).
mu: a unit norm vector of size p giving the axis of rotational symmetry.
kappa: the strength of the local alternative, between 0
and 1.
n: sample size, a positive integer.
F_inv: quantile function associated to f. Computed by F_inv_from_f if NULL (default).
...: further parameters passed to F_inv_from_f.
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.
type: name of the Sobolev statistic, using the naming from avail_cir_tests and avail_sph_tests.
Rothman_t: t parameter for the Rothman test, a real in (0,1). Defaults to 1 / 3.
Pycke_q: q parameter for the Pycke "q-test", a real in (0,1). Defaults to 1 / 2.
verbose: output information about the truncation (TRUE or 1) and a diagnostic plot (2)? Defaults to FALSE.
Gauss: use a Gauss--Legendre quadrature rule of N nodes in the computation of the Gegenbauer coefficients? Otherwise, call integrate. Defaults to TRUE.
tol: tolerance passed to integrate's rel.tol and abs.tol if Gauss = FALSE. Defaults to 1e-6.
Returns
f_locdev: angular function evaluated at x, a vector.
con_f: normalizing constant cf of f, a scalar.
d_locdev: density function evaluated at x, a vector.
r_locdev: a matrix of size c(n, p) containing a random sample from the density c("\n", "fkappa,mu").
cutoff_locdev: vector of coefficients {uk,p}
automatically truncated according to K_max and thre
(see details).
Description
Density and random generation for local projected alternatives to uniformity with densities
is the angular function controlling the local alternative in a Gegenbauer series , 0≤κ≤1, μ is a direction on Sp−1, and ωp is the surface area of Sp−1. The sequence {uk,p} is typically such that c("\n", "uk,p=(1+2k/(p−2))bk,p") for the Gegenbauer coefficients {bk,p} of the kernel function of a Sobolev statistic (see the transformation between the coefficients uk,p
and bk,p).
Also, automatic truncation of the series ∑k=1∞uk,pCk(p/2−1)(z)
according to the proportion of "Gegenbauer norm"
explained.
Details
See the definitions of local alternatives in Prentice (1978) and in García-Portugués et al. (2023).
The truncation of c("\n", "\\sum_{k = 1}^\\infty u_{k, p} C_k^(p / 2 - 1)(z)") is done to the first K_max terms and then up to the index such that the first terms leave unexplained the proportion thre of the norm of the whole series. Setting thre = 0 truncates to K_max terms exactly. If the series only contains odd or even non-zero terms, then only K_max / 2
addends are effectively taken into account in the first truncation.
Examples
## Local alternatives diagnosticsloc_alt_diagnostic <-function(p, type, thre =1e-3, K_max =1e3){# Coefficients of the alternative uk <- cutoff_locdev(K_max = K_max, p = p, type = type, thre = thre, N =640) old_par <- par(mfrow = c(2,2))# Construction of f z <- seq(-1,1, l =1e3) f <-function(z) f_locdev(z = z, p = p, uk = uk) plot(z, f(z), type ="l", xlab = expression(z), ylab = expression(f(z)), main = paste0("Local alternative f, ", type,", p = ", p), log ="y")# Projected density on [-1, 1] f_proj <-function(z) rotasym::w_p(p = p -1)* f(z)*(1- z^2)^((p -3)/2) plot(z, f_proj(z), type ="l", xlab = expression(z), ylab = expression(omega[p -1]* f(z)*(1- z^2)^{(p -3)/2}), main = paste0("Projected density, ", type,", p = ", p), log ="y", sub = paste("Integral:", round(con_f(f = f, p = p),4)))# Quantile function for projected density mu <- c(rep(0, p -1),1) F_inv <- F_inv_from_f(f = f, p = p, K =5e2) plot(F_inv, xlab = expression(x), ylab = expression(F^{-1}*(x)), main = paste0("Quantile function, ", type,", p = ", p))# Sample from the alternative and plot the projected sample n <-5e4 samp <- r_locdev(n = n, mu = mu, f = f, kappa =1, F_inv = F_inv) plot(z, f_proj(z), col =2, type ="l", main = paste0("Simulated projected data, ", type,", p = ", p), ylim = c(0,1.75)) hist(samp %*% mu, freq =FALSE, breaks = seq(-1,1, l =50), add =TRUE) par(old_par)}## Local alternatives for the PCvM testloc_alt_diagnostic(p =2, type ="PCvM")loc_alt_diagnostic(p =3, type ="PCvM")loc_alt_diagnostic(p =4, type ="PCvM")loc_alt_diagnostic(p =5, type ="PCvM")loc_alt_diagnostic(p =11, type ="PCvM")## Local alternatives for the PAD testloc_alt_diagnostic(p =2, type ="PAD")loc_alt_diagnostic(p =3, type ="PAD")loc_alt_diagnostic(p =4, type ="PAD")loc_alt_diagnostic(p =5, type ="PAD")loc_alt_diagnostic(p =11, type ="PAD")## Local alternatives for the PRt testloc_alt_diagnostic(p =2, type ="PRt")loc_alt_diagnostic(p =3, type ="PRt")loc_alt_diagnostic(p =4, type ="PRt")loc_alt_diagnostic(p =5, type ="PRt")loc_alt_diagnostic(p =11, type ="PRt")
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") .
Prentice, M. J. (1978). On invariant tests of uniformity for directions and orientations. The Annals of Statistics, 6(1):169--176. tools:::Rd_expr_doi("10.1214/aos/1176344075")