R: Estimation of the Mode

mlv {modeest} | R Documentation

## Estimation of the Mode

### Description

`mlv` is a generic function which enables to compute an estimate of the mode of a univariate distribution. Many 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.

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

A 'plot' and a 'print' methods are provided.

### Usage

    mlv(x,
        ...)

      ## Default S3 method:
    mlv(x,
        bw = NULL,
        method,
        na.rm = FALSE,
        boot = FALSE,
        R = 100,
        B = length(x),
        ...)

      ## S3 method for class 'factor'
    mlv(x,
        ...)

      ## S3 method for class 'integer'
    mlv(x,
        na.rm = FALSE,
        ...)

      ## S3 method for class 'character'
    mlv(x,
        ...)

      ## S3 method for class 'density'
    mlv(x,
        all = TRUE,
        abc = FALSE,
        ...)

      ## S3 method for class 'mlv'
    plot(x,
         ...)

      ## S3 method for class 'mlv'
    print(x,
          digits = NULL,
          ...)

      ## S3 method for class 'mlv'
    as.numeric(x,
               ...)

### Arguments

`x` | numeric (vector of observations), or an object of class `"factor"`, `"integer"`, etc. For the function `as.numeric`, an object of class `"mlv"`.
`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'.
`na.rm` | logical. Should missing values be removed?

`boot` | logical. Should bootstrap resampling be done?
`R` | numeric. If `boot = TRUE`, the number of bootstrap resampling rounds to use.
`B` | numeric. If `boot = TRUE`, the size of the bootstrap samples drawn from `x`. Default is to use a sample which is the same size as data. For large data sets, this may be slow and unnecessary.
`all` | logical.
`abc` | logical. If `FALSE` (the default), the estimate of the density function is maximised using `optim`.
`digits` | numeric. Number of digits to be printed.
`...` | Further arguments to be passed to the function called for computation. This function is related to the `method` argument.

### Details

For the function `mlv.default`, available methods are `"mfv"`, `"lientz"`, `"naive"`, `"venter"`, `"grenander"`, `"hsm"`, `"hrm"`, `"parzen"`, `"tsybakov"`, and `"asselin"`. See the description above and the associated links.
If `x` is of class `"factor"` or `"integer"`, the most frequent value found in `x` is returned.
If `x` is of class `"character"`, `x` should be one of `"beta"`, `"cauchy"`, `"gev"`, etc. i.e. a character for which a function `'x'Mode` exists (for instance `betaMode`, `cauchyMode`, etc.). See `distribMode` for the available functions. The mode of the corresponding distribution is returned.
If `x` is of class `"density"`, the value where the density is maximised is returned.
For the S3 function `mlv.lientz`, see `Lientz` for more details.

### Value

`mlv` returns an object of `class` `"mlv"`.
An object of class `"mlv"` is a list containing at least the following components:

`M` | the value of the mode
`skewness` | Bickel's measure of `skewness`
`x` | the argument `x`
`method` | the argument `method`
`bw` | the bandwidth

`boot` | the argument `boot`
`boot.M` | if `boot = TRUE`, the resampled values of the mode
`call` | the call which produced the result

### Author(s)

P. Poncet

### References

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

### See Also

`mfv`, `Lientz`, `naive`, `venter`, `grenander`, `hrm`, `hsm`, `parzen`, `tsybakov`, `skewness`

### Examples

    # Unimodal distribution
    x <- rbeta(1000,23,4)

    ## True mode
    betaMode(23, 4)
    # or
    mlv("beta", 23, 4)

    ## 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 = "hrm", bw = 0.3)
    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")

    ## Bootstrap
    M <- mlv(x, method = "kernel", boot = TRUE, R = 150)
    print(M)
    plot(M)
    print(mean(M[["boot.M"]]))

[Package modeest version 2.1 Index]