locdev: Local projected alternatives to uniformity

locdevR Documentation

Local projected alternatives to uniformity

Description

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.

Usage

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)

Arguments

z

projected evaluation points for f, a vector with entries on [-1, 1].

p

integer giving the dimension of the ambient space R^p that contains S^{p-1}.

uk

coefficients u_{k, 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 S^{p-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

Sobolev statistic. For p = 2, either "Watson", "Rothman", "Pycke_q", or "Hermans_Rasson". For p \ge 2, "Ajne", "Gine_Gn", "Gine_Fn", "Bakshaev", "Riesz", "PCvM", "PAD", or "PRt".

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.

Details

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.

Value

  • 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).

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. \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")}

Examples

## 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")


sphunif documentation built on Aug. 21, 2023, 9:11 a.m.