mlv: Estimation of the Mode(s) or Most Likely Value(s)

Description Usage Arguments Details Value References See Also Examples

View source: R/mlv.R

Description

mlv is a generic function for estimating the mode of a univariate distribution. Different estimates (or methods) are provided:

mlv can also be used to compute the mode of a given distribution, with mlv.character.

Usage

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

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

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.

Value

A vector of the same type as x. Be aware that the length of this vector can be > 1.

References

See the references on mode estimation on the modeest-package's page.

See Also

mfv, parzen, venter, meanshift, grenander, hsm, lientz, naive, tsybakov, skewness

Examples

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

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