excessmass {multimode} | R Documentation |
Excess mass
Description
This function computes the excess mass statistic.
Usage
excessmass(data,mod0=1,approximate=FALSE,gridsize=NULL,full.result=F)
Arguments
data |
Sample for computing the excess mass. |
mod0 |
Number of modes for which the excess mass is calculated. Default |
approximate |
If this argument is TRUE then the excess mass value is approximated. Default |
gridsize |
When |
full.result |
If this argument is TRUE then it returns the full result list, see below. Default |
Details
With excessmass
, the excess mass test statistic, introduced by Müller and Sawitzki (1991), for the integer number of modes specified in mod0
is computed.
The excess mass test statistic for k modes is defined as , where
. The empirical excess mass function for
modes is defined as
, being the sets
closed intervals with endpoints the data points.
When mod0>1
and the sample size is large, a two-steps approximation (approximate=TRUE
) can be performed in order to improve the computing time efficiency. First, since the possible candidates to maximize
can be directly obtained from the sets that maximize
and
(see Section SM5 of Supplementary Material in Ameijeiras-Alonso et al., 2019), the possible values of
are computed by looking to the empirical excess mass function in
gridsize[1]
endpoints candidates for and also in the
values associated to the empirical excess mass for one mode. Once a
maximizing the approximated values of
is chosen, in order to obtain the approximation of the excess mass test statistic, in its neighborhood, a grid of possible values of
is created, being its length equal to
gridsize[2]
, and the exact value of is calculated for these values of
(using the algorithm proposed by Müller and Sawitzki, 1991).
If there are repeated data in the sample or the distance between different pairs of data points shows ties, a data perturbation is applied. This modification is made in order to avoid the discretization of the data which has important effects on the computation of the test statistic. The perturbed sample is obtained by adding a sample from the uniform distribution in minus/plus a half of the minimum of the positive distances between two sample points.
The NAs will be automatically removed.
Value
Depending on full.result
either a number, the excess mass statistic for mod0
modes, or an object of class "estmod"
which is a list
containing the following components:
nmodes |
The specified hypothesized value of the number of modes. |
sample.size |
The number of non-missing observations in the sample used for computing the excess mass. |
excess.mass |
Value of the excess mass test statistic. |
approximate |
A logical value indicating if the excess mass was approximated. |
Author(s)
Jose Ameijeiras-Alonso, Rosa M. Crujeiras and Alberto Rodríguez-Casal
References
Ameijeiras-Alonso, J., Crujeiras, R.M. and Rodríguez-Casal, A. (2019). Mode testing, critical bandwidth and excess mass, Test, 28, 900–919.
Ameijeiras-Alonso, J., Crujeiras, R.M. and Rodríguez-Casal, A. (2021). multimode: An R Package for Mode Assessment, Journal of Statistical Software, 97, 1–32.
Müller, D. W. and Sawitzki, G. (1991). Excess mass estimates and tests for multimodality, The Annals of Statistics, 13, 70–84.
Examples
# Excess mass statistic for one mode
set.seed(2016)
data=rnorm(50)
excessmass(data)