hsm: Half sample mode estimator

Description Usage Arguments Details Value Note Author(s) References See Also Examples

View source: R/hsm.R

Description

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).

Usage

1
hsm(x, bw = NULL, k, tie.action = "mean", tie.limit = 0.05, ...)

Arguments

x

numeric. Vector of observations.

bw

numeric or function. The bandwidth to be used. Should belong to (0, 1].

k

numeric. See 'Details'.

tie.action

character. The action to take if a tie is encountered.

tie.limit

numeric. A limit deciding whether or not a warning is given when a tie is encountered.

...

Additional arguments.

Details

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 i, one takes k = ceiling(bw*n) - 1, where n is the length of the modal interval computed at step i-1. If bw is of class "function", then k = ceiling(bw(n)) - 1 instead.

Value

A numeric value is returned, the mode estimate.

Note

The user may call hsm through mlv(x, method = "hsm", ...).

Author(s)

D.R. Bickel for the original code, P. Poncet for the slight modifications introduced.

References

See Also

mlv for general mode estimation; venter for the Venter mode estimate.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
# 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)

modeest documentation built on Nov. 18, 2019, 5:07 p.m.