Robust bandwidth estimation for kernel density estimation
Source:R/kde_bandwidth.R
kde_bandwidth.RdBandwidth matrices are estimated using either a robust version of the normal reference rule, or using the approach of Hyndman, Kandanaarachchi & Turner (2026).
Usage
kde_bandwidth(data, method = c("robust", "normal", "plugin", "lookout"), ...)Arguments
- data
A numeric matrix or data frame.
- method
A character string giving the method to use. Possibilities are:
"normal"(normal reference rule),"robust"(a robust version of the normal reference rule, the default),"plugin"(a plugin estimator), and"lookout"(the bandwidth matrix estimate of Hyndman, Kandanaarachchi & Turner, 2026).- ...
Additional arguments are ignored unless
method = "lookout", when they are passed tolookout::find_tda_bw().
References
Rob J Hyndman, Sevvandi Kandanaarachchi & Katharine Turner (2026) "When lookout sees crackle: Anomaly detection via kernel density estimation", unpublished. https://robjhyndman.com/publications/lookout2/
Rob J Hyndman (2026) "That's weird: Anomaly detection using R", https://OTexts.com/weird/
Examples
# Univariate bandwidth calculation
kde_bandwidth(oldfaithful$duration)
#> [1] 5.087698
# Bivariate bandwidth calculation
kde_bandwidth(oldfaithful[, c("duration", "waiting")])
#> [,1] [,2]
#> [1,] 40.53793 349.3449
#> [2,] 349.34486 22918.0734