This function computes the Robertson-Cryer mode estimator
described in Robertson and Cryer (1974),
also called half sample mode (if bw = 1/2
)
or fraction sample mode (for some other bw
) by Bickel (2006).
hsm(x, bw = NULL, k, tie.action = "mean", tie.limit = 0.05, ...)
numeric. Vector of observations.
numeric or function. The bandwidth to be used. Should belong to (0, 1].
numeric. See 'Details'.
character. The action to take if a tie is encountered.
numeric. A limit deciding whether or not a warning is given when a tie is encountered.
Additional arguments.
A numeric value is returned, the mode estimate.
The modal interval, i.e. the shortest interval among
intervals containing k+1
observations, is computed
iteratively, until only one value is found, the mode estimate.
At each step k = ceiling(bw*n) - 1
,
where n
is the length of the modal interval computed
at step 1
.
If bw
is of class "function"
,
then k = ceiling(bw(n)) - 1
instead.
Robertson T. and Cryer J.D. (1974). An iterative procedure for estimating the mode. J. Amer. Statist. Assoc., 69(348):1012-1016.
Bickel D.R. and Fruehwirth R. (2006). On a Fast, Robust Estimator of the Mode: Comparisons to Other Robust Estimators with Applications. Computational Statistics and Data Analysis, 50(12):3500-3530.
mlv
for general mode estimation;
venter
for the Venter mode estimate.
# NOT RUN {
# Unimodal distribution
x <- rweibull(10000, shape = 3, scale = 0.9)
## True mode
weibullMode(shape = 3, scale = 0.9)
## Estimate of the mode
bandwidth <- function(n, alpha) {1/n^alpha}
hsm(x, bw = bandwidth, alpha = 2)
mlv(x, method = "hsm", bw = bandwidth, alpha = 2)
# }
Run the code above in your browser using DataLab