h.tcv: Trimmed Cross-Validation for Bandwidth Selection

View source: R/h.tcv.R

h.tcvR Documentation

Trimmed Cross-Validation for Bandwidth Selection

Description

Computes the trimmed cross-validation bandwidth selector of the r'th derivative of a kernel density estimator (one-dimensional). Returns an S4 object of class bandwidth.

Usage

h.tcv(x, deriv.order = 0L, kernel = "gaussian",
      lower, upper, tol, nthreads = 0L)

Arguments

x

numeric vector of data values.

deriv.order

non-negative integer: derivative order r. Maximum r for this selector: any for Gaussian and Silverman; cosine 1; logistic 8; Epanechnikov 1; uniform 0; triangular 0; biweight 2; triweight 3; tricube 3; pow(s,t) \min(r^*, 6), where r^* is the largest integer r < t + 1/2 (and r < s + 1/2 if s is not an even integer, and 2r \le st if s and t are integers). Above it h = NA is returned with a warning. See kedd-package, section ‘Maximum derivative order’.

kernel

character string giving the kernel; one of "gaussian" (default), "epanechnikov", "uniform", "triangular", "biweight", "triweight", "tricube", "cosine", "silverman", "logistic", or a power kernel "pow(s,t)" (see kernel.pow).

lower, upper

bounds of the search interval. Defaults to [0.01 * hos, 2 * hos].

tol

convergence tolerance for optimize. Default 0.01 * lower (after validation of lower).

nthreads

number of OpenMP threads for this call: 0 (default) = all processors, k > 0 = k threads, both capped by the environment variable OMP_THREAD_LIMIT. The result does not depend on it, and it never changes the threads used by later calls.

Details

Feluch and Koronacki (1992) proposed trimmed cross-validation (TCV), a modification of unbiased cross-validation that trims small pairwise distances. \hat{h}_{TCV}^{(r)} minimises:

TCV(h;r) = \frac{R(K^{(r)})}{nh^{2r+1}} + \frac{(-1)^r}{n(n-1)h^{2r+1}} \sum_i\sum_{j \neq i} \varphi^{(r)}\!\left(\frac{X_j-X_i}{h}\right)

where

\varphi^{(r)}(c) = \Bigl(K^{(r)}\ast K^{(r)} - 2\,K^{(2r)}\chi\!\bigl(|c|>c_n/h^{2r+1}\bigr)\Bigr)(c)

with c_n=1/n (ensuring convergence), \chi(.) the indicator function, and K^{(r)}\ast K^{(r)} the convolution of the r'th kernel derivative (see kernel.conv, kernel.fun).

The search is bounded by the over-smoothing bandwidth hos (Scott 1992, p.\,165; Wand and Jones 1995, p.\,61).

Value

An S4 object of class bandwidth with slots:

data

the (cleaned) data vector.

kernel

name of the kernel used.

deriv.order

derivative order r.

h

selected bandwidth.

min.obj

minimum TCV value.

hos

over-smoothing bandwidth (upper bound).

method

"TCV".

Author(s)

Arsalane Chouaib Guidoum acguidoum@univ-tam.dz, Amel Henider amel.henider@univ-tam.dz and Iago Giné-Vázquez iago.gin-vaz@protonmail.com

References

Feluch, W. and Koronacki, J. (1992). A note on modified cross-validation in density estimation. Computational Statistics and Data Analysis, 13, 143–151.

Wand, M. P. and Jones, M. C. (1995). Kernel Smoothing. Chapman and Hall, London.

See Also

bandwidth, h.ucv, h.bcv, h.ccv, h.mcv, h.amise, h.scv, kernel.conv, kernel.fun.

Examples

x <- rnorm(100)

## density (r = 0)
bw0 <- h.tcv(x, deriv.order = 0)
show(bw0)
plot(bw0)

## first derivative (r = 1)
bw1 <- h.tcv(x, deriv.order = 1)
show(bw1)
## other kernels on a Marron-Wand sample
h.tcv(kurtotic, kernel = "logistic")
h.tcv(kurtotic, kernel = "pow(2,3)")

kedd documentation built on Nov. 12, 2026, 5:10 p.m.