mlv is a generic function for estimating the mode of a univariate distribution. Different estimates (or methods) are provided:
mfv, which returns the most frequent value(s) in a given numerical vector,
the Lientz mode estimator, which is the value minimizing the Lientz function estimate,
the Chernoff mode estimator, also called naive mode estimator, which is defined as the center of the interval of given length containing the most observations,
the Venter mode estimator, including the shorth, i.e. the midpoint of the modal interval,
the Grenander mode estimator,
the half sample mode (HSM) and the half range mode (HRM), which are iterative versions of the Venter mode estimator,
Parzen's kernel mode estimator, which is the value maximizing the kernel density estimate,
the Tsybakov mode estimator, based on a gradient-like recursive algorithm,
the Asselin de Beauville mode estimator, based on a algorithm detecting chains and holes in the sample,
the Vieu mode estimator,
the meanshift mode estimator.
mlv can also be used to compute the mode of a given distribution, with mlv.character.
mlv(x,...)## S3 method for class 'character'mlv(x, na.rm =FALSE,...)## S3 method for class 'factor'mlv(x, na.rm =FALSE,...)## S3 method for class 'logical'mlv(x, na.rm =FALSE,...)## S3 method for class 'integer'mlv(x, na.rm =FALSE,...)## Default S3 method:mlv(x, bw =NULL, method, na.rm =FALSE,...)mlv1(x,...)
Arguments
x: numeric (vector of observations), or an object of class "factor", "integer", etc.
...: Further arguments to be passed to the function called for computation.
na.rm: logical. Should missing values be removed?
bw: numeric. The bandwidth to be used. This may have different meanings regarding the method used.
method: character. One of the methods available for computing the mode estimate. See 'Details'.
Returns
A vector of the same type as x. Be aware that the length of this vector can be > 1.
Details
For the default method of mlv, available methods are "lientz", "naive", "venter", "grenander", "hsm", "parzen", "tsybakov", "asselin", and "meanshift". See the description above and the associated links.
If x is of class "character" (with length > 1), "factor", or "integer", then the most frequent value found in x is returned using mfv from package statip.
If x is of class "character" (with length 1), x should be one of "beta", "cauchy", "gev", etc. i.e. a character for which a function *Mode exists (for instance betaMode, cauchyMode, etc.). See distrMode for the available functions. The mode of the corresponding distribution is returned.
If x is of class mlv.lientz, see Lientz
for more details.
Examples
# Unimodal distributionx <- rbeta(1000,23,4)## True modebetaMode(23,4)# ormlv("beta", shape1 =23, shape2 =4)## Be aware of this behaviour: mlv("norm")# returns 0, the mode of the standard normal distributionmlv("normal")# returns 0 again, since "normal" is matched with "norm"mlv("abnormal")# returns "abnormal", since the input vector "abrnormal" # is not recognized as a distribution name, hence is taken as a character # vector from which the most frequent value is requested. ## Estimate of the modemlv(x, method ="lientz", bw =0.2)mlv(x, method ="naive", bw =1/3)mlv(x, method ="venter", type ="shorth")mlv(x, method ="grenander", p =4)mlv(x, method ="hsm")mlv(x, method ="parzen", kernel ="gaussian")mlv(x, method ="tsybakov", kernel ="gaussian")mlv(x, method ="asselin", bw =2/3)mlv(x, method ="vieu")mlv(x, method ="meanshift")
References
See the references on mode estimation on the modeest-package's page.