mlv {modeest} | R Documentation |
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,
Lientz
mode estimator, which is the value minimizing the Lientz function estimate,
naive
mode estimator, which is defined as the
center of the interval of given length containing the most observations,
Venter
mode estimator, including the shorth
, i.e. the midpoint of the modal interval,
Grenander
mode estimator,
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,
Tsybakov
mode estimator, based on a gradient-like recursive algorithm,
Asselin
de Beauville 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.
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, ...)
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. |
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.
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 |
Paul Poncet paulponcet@yahoo.fr
See the references on mode estimation on the modeest-package
's page.
mfv
,
Lientz
,
naive
,
venter
,
grenander
,
hrm
,
hsm
,
parzen
,
tsybakov
,
skewness
# 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) ## Bootstrap M <- mlv(x, method = "kernel", boot = TRUE, R = 150) print(M) plot(M) print(mean(M[["boot.M"]]))