Learn R Programming

Laurae (version 0.0.0.9001)

bandwidth_rot: MASS' Rule of Thumb Bandwidth Estimation

Description

A well-supported rule-of-thumb for choosing the bandwidth of a Gaussian kernel density estimator.

Usage

bandwidth_rot(x)

Arguments

x
Type: numeric vector. A data vector.

Value

A bandwidth on a scale suitable for the width argument of density.

Examples

Run this code
## Not run: ------------------------------------
# #?MASS::bandwidth.nrd
# bandwidth_rot <- function (x) {
#   r <- quantile(x, c(0.25, 0.75))
#   h <- (r[2L] - r[1L])/1.34
#   4 * 1.06 * min(sqrt(var(x)), h) * length(x)^(-1/5)
# }
## ---------------------------------------------

Run the code above in your browser using DataLab