| bwLscvg | R Documentation |
This function computes the optimal smoothing parameter (bandwidth) for circular data using a generalized least squares cross-validation method (see \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1007/s00180-023-01401-0")}).
bwLscvg(x, g = NULL, lower = 0, upper = 60, tol = 0.1)
x |
Data from which the smoothing parameter is to be computed. The object is
coerced to a numeric vector in radians using |
g |
A numeric scalar that controls the variability in the cross-validation procedure. It influences the scaling in the internal calculations, affecting the bandwidth estimation. It needs to be positive number not equal to 2. Default is 4. |
lower |
Lower boundary of the interval to be used in the search for the
smoothing parameter |
upper |
Upper boundary of the interval to be used in the search for the
smoothing parameter |
tol |
Convergence tolerance for the |
The generalized least squares cross-validation method (LSCV_g) is an adaptation of the method originally introduced by Zhang for linear data, developed for circular data (see Zamecnik, et.al 2025) to address the finite-sample performance issues of standard LSCV.
The LSCV_g criterion is defined as:
LSCV_g(\kappa) = \frac{1}{n}R(K_{\kappa}) + \frac{1}{n(n-1)} \sum_{i=1}^n \sum_{j \neq i}^n \left(\frac{n-1}{n} (K_{\kappa}*K_{\kappa})(\theta_i-\theta_j) + \frac{2}{g(g-2)} K_{\kappa/g}(\theta_i-\theta_j) - \frac{g-1}{g-2} K_{\kappa/2}(\theta_i-\theta_j)\right)
Using the von Mises kernel, this takes the computational form:
LSCV_g(\kappa) = \frac{1}{2\pi n^2} \sum_{i=1}^n \sum_{j=1}^n \frac{I_0(\kappa \sqrt{2(1+\cos(\theta_i-\theta_j))})}{I_0^2(\kappa)} + \frac{1}{n(n-1)} \sum_{i=1}^n \sum_{j \neq i}^n \left(\frac{2}{g(g-2)} \frac{\exp(\frac{\kappa}{g}\cos(\theta_i-\theta_j))}{2\pi I_0(\kappa/g)} - \frac{g-1}{g-2} \frac{\exp(\frac{\kappa}{2}\cos(\theta_i-\theta_j))}{2\pi I_0(\kappa/2)}\right)
The optimal bandwidth is obtained by minimizing this criterion over the interval
[lower, upper].
The computed optimal smoothing parameter kappa, a numeric concentration
parameter (analogous to inverse radians) that minimizes the smoothed cross-validation
criterion within the interval [lower, upper] and the value of objective function
at that point. Higher values indicate sharper, more concentrated kernels and less
smoothing; lower values indicate broader kernels and more smoothing. If the
optimization fails, a warning is issued.
Zámečník, S., Horová, I., & Hasilová, K. (2025). Generalised least square cross-validation for circular data. Communications in Statistics. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1007/s00180-023-01401-0")}
Zhang, J. (2015). Generalized least squares cross-validation in kernel density estimation. Statistica Neerlandica, 69(3), 315-328. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1111/stan.12061")}
bwScv, bwFo, bwCcv
# Example with circular data
library(circular)
set.seed(123)
x <- rwrappednormal(100, mu = circular(2), rho = 0.5)
bw <- bwLscvg(x)
print(round(bw$minimum, 2))
x <- rvonmises(100, mu = circular(0), kappa = 1)
bw <- bwLscvg(x)
print(round(bw$minimum, 2))
plot(density.circular(x, bw = bw$minimum))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.