Skip to contents

Bandwidth matrices are estimated in several ways including a normal reference rule, a robust version of the normal reference rule (default), a plugin estimator, a smoothed cross-validation estimator, or using the approach of Hyndman, Kandanaarachchi & Turner (2026). Details of each method are given in Hyndman (2026).

Usage

kde_bandwidth(
  data,
  method = c("robust", "normal", "plugin", "scv", "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), "scv" (a smoothed cross-validation estimator), and "lookout" (the bandwidth matrix estimate of Hyndman, Kandanaarachchi & Turner, 2026).

...

Additional arguments are ignored.

Value

A matrix of bandwidths (or a scalar in the case of univariate data).

References

Hyndman, R J, Kandanaarachchi, S & Turner, K (2026) "When lookout sees crackle: Anomaly detection via kernel density estimation", unpublished. https://robjhyndman.com/publications/lookout2.html

Hyndman, R J (2026) "That's weird: Anomaly detection using R", Section 2.9 and 3.9, https://OTexts.com/weird/.

Author

Rob J Hyndman

Examples

# Univariate bandwidth calculation
kde_bandwidth(oldfaithful$duration)
#> [1] 5.087698
# Bivariate bandwidth calculation
kde_bandwidth(oldfaithful[, c("duration", "waiting")])
#>           duration   waiting
#> duration  36.75439   287.378
#> waiting  287.37804 16331.163