| locdev | R Documentation | 
Density and random generation for local projected alternatives to uniformity with densities
f_{\kappa, \boldsymbol{\mu}}({\bf x}): =
\frac{1 - \kappa}{\omega_p} + \kappa f({\bf x}'\boldsymbol{\mu})
where
f(z) = \frac{1}{\omega_p}\left\{1 + \sum_{k = 1}^\infty u_{k, p}
C_k^{p / 2 - 1}(z)\right\}
is the angular function controlling the local alternative in a
Gegenbauer series, 0\le \kappa \le 1,
\boldsymbol{\mu} is a direction on S^{p - 1}, and
\omega_p is the surface area of S^{p - 1}. The sequence
\{u_{k, p}\} is typically such that
u_{k, p} = \left(1 + \frac{2k}{p - 2}\right) b_{k, p} for the Gegenbauer coefficients
\{b_{k, p}\} of the kernel function of a Sobolev statistic (see the
transformation between the coefficients u_{k, p}
and b_{k, p}).
Also, automatic truncation of the series \sum_{k = 1}^\infty u_{k, p}
C_k^{p / 2 - 1}(z)
according to the proportion of "Gegenbauer norm"
explained.
f_locdev(z, p, uk)
con_f(f, p, N = 320)
d_locdev(x, mu, f, kappa)
r_locdev(n, mu, f, kappa, F_inv = NULL, ...)
cutoff_locdev(p, K_max = 10000, thre = 0.001, type, Rothman_t = 1/3,
  Pycke_q = 0.5, verbose = FALSE, Gauss = TRUE, N = 320, tol = 1e-06)
| z | projected evaluation points for  | 
| p | integer giving the dimension of the ambient space  | 
| uk | coefficients  | 
| f | angular function defined on  | 
| N | number of points used in the 
Gauss–Legendre quadrature for computing the Gegenbauer coefficients.
Defaults to  | 
| x | locations in  | 
| mu | a unit norm vector of size  | 
| kappa | the strength of the local alternative, between  | 
| n | sample size, a positive integer. | 
| F_inv | quantile function associated to  | 
| ... | further parameters passed to  | 
| 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  | 
| type | name of the Sobolev statistic, using the naming from
 | 
| Rothman_t | 
 | 
| Pycke_q | 
 | 
| verbose | output information about the truncation ( | 
| Gauss | use a Gauss–Legendre quadrature rule of  | 
| tol | tolerance passed to  | 
See the definitions of local alternatives in Prentice (1978) and in García-Portugués et al. (2023).
The truncation of \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.
f_locdev: angular function evaluated at x, a vector.
con_f: normalizing constant c_f 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 f_{\kappa, \boldsymbol{\mu}}.
cutoff_locdev: vector of coefficients \{u_{k, p}\}
automatically truncated according to K_max and thre
(see details).
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. \Sexpr[results=rd]{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. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1214/aos/1176344075")}
## Local alternatives diagnostics
loc_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 test
loc_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 test
loc_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 test
loc_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")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.