bandwidths: Bandwidth Selectors

bandwidthsR Documentation

Bandwidth Selectors

Description

The available options for bandwidth selectors, passed as the bw argument to kdensity.

Details

The bandwidth functions are not exported. They are members of the environment bw_environment, and can be accessed by kdensity:::bw_environment.

Defaults

Every default is a closed-form rule, so no default requires cross-validation:

Kernel Uniform start Parametric start
symmetric (gaussian, ...) "nrd0" "RHE"
gamma, gamma_biased "GR" "GR"
beta, beta_biased "HS" "HS"
gcopula "SJ" "SJ"
custom kernel without sd "ucv" "ucv"

The rules use only the data, not the fitted parametric start. When the start fits well, the correction it leaves for the kernel is smoother than the density itself, so a larger bandwidth would be better; the rules then undersmooth slightly. "ucv" takes the start into account at the cost of a computation that grows with the square of the sample size.

Bandwidth selectors

⁠"nrd0", "nrd", "bcv"⁠: Bandwidth selectors from stats, documented in stats::bw.nrd0(). They are on the scale of the Gaussian kernel's standard deviation; kdensity rescales them for the other symmetric kernels.

"SJ": The Sheather & Jones (1991) plug-in selector stats::bw.SJ(). For the gcopula kernel it is applied on the probit scale: there the Gaussian copula estimator is a Gaussian kernel estimate with bandwidth s = sqrt(1 - rho^2), where rho = 1 - h^2, so the selected s is converted to h = sqrt(1 - sqrt(1 - s^2)). If the selector fails on degenerate data, "JH" is used with a warning.

"ucv": Unbiased cross-validation. With a parametric start it refits the start without each observation, so its cost grows with the square of the sample size.

"HS": Hallberg Szabadváry's closed-form reference rule for the bias-corrected beta kernel, based on a beta reference density fitted by moments. Used for both beta kernels, with a fallback heuristic when the rule's moment conditions fail.

"GR": Chen's AMISE-optimal bandwidth for the bias-corrected gamma kernel, with the unknown density replaced by a gamma reference fitted by maximum likelihood to the positive observations. The fitted shape is floored at 3, keeping the fitted mean: the rule needs a shape above 3/2, and the floor was the most robust choice in simulations with exponential, lognormal, Weibull and mixture targets. Used for both gamma kernels.

"RHE": A reference rule for symmetric kernels that estimates the roughness of the density with Hermite polynomials around a fitted normal density. It uses only the data, not the parametric start.

"JH": Jones & Henderson's normal-reference rule for the Gaussian copula kernel. Accurate for unimodal data, but it oversmooths multimodal data badly; capped at 0.5.

Structure

The bandwidth selector is a function of four arguments: The data x, a kernel string kernel, a start string start, and a support vector support. To obtain the functions associated with these strings, use get_kernel and get_start. The function should return a double.

References

Jones, M. C., and D. A. Henderson. "Kernel-type density estimation on the unit interval." Biometrika 94.4 (2007): 977-984. Hjort, Nils Lid, and Ingrid K. Glad. "Nonparametric density estimation with a parametric start." The Annals of Statistics (1995): 882-904. Hallberg Szabadváry, Johan. "A Fast, Closed-Form Bandwidth Selector for the Beta Kernel Density Estimator." arXiv preprint arXiv:2601.19553 (2026). Sheather, S. J., and M. C. Jones. "A reliable data-based bandwidth selection method for kernel density estimation." Journal of the Royal Statistical Society: Series B 53.3 (1991): 683-690. Chen, Song Xi. "Probability density function estimation using gamma kernels." Annals of the Institute of Statistical Mathematics 52.3 (2000): 471-480.

See Also

kdensity(), stats::bandwidth.kernel() for the bandwidth selectors of stats::density(). In addition, kernels(); parametric_starts()

Examples

## Not a serious bandwidth function.
silly_width <- function(x, kernel = NULL, start = NULL, support = NULL) {
  rexp(1)
}
kdensity(mtcars$mpg, start = "gumbel", bw = silly_width)

kdensity documentation built on Oct. 28, 2026, 5:06 p.m.