Description Usage Arguments Details Value References See Also Examples
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
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | 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, ...)
|
x |
numeric (vector of observations), or an object of class |
... |
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 |
character. One of the methods available for computing the mode estimate. See '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.
A vector of the same type as x
.
Be aware that the length of this vector can be > 1
.
See the references on mode estimation on the modeest-package
's page.
mfv
,
parzen
,
venter
,
meanshift
,
grenander
,
hsm
,
lientz
,
naive
,
tsybakov
,
skewness
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | # Unimodal distribution
x <- rbeta(1000,23,4)
## True mode
betaMode(23, 4)
# or
mlv("beta", shape1 = 23, shape2 = 4)
## Be aware of this behaviour:
mlv("norm") # returns 0, the mode of the standard normal distribution
mlv("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 mode
mlv(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")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.