locmodes {multimode} | R Documentation |
Location of modes and antimodes
Description
Given a certain number of modes, this function provides the estimation of the location of modes and antimodes and their density value.
Usage
locmodes(data,mod0=1,lowsup=-Inf,uppsup=Inf,n=2^15,tol=10^(-5),display=F,...)
## S3 method for class 'locmod'
plot(x,addplot=NULL,xlab=NULL,ylab=NULL,addLegend=NULL,posLegend=NULL,...)
## S3 method for class 'locmod'
print(x,digits=getOption("digits"), ...)
Arguments
data |
Sample in which the critical bandwidth is computed. |
mod0 |
Number of modes for which the critical bandwidth is calculated. Default |
lowsup |
Lower limit for the random variable support in the computation of the critical bandwidth. Default is |
uppsup |
Upper limit for the random variable support in the computation of the critical bandwidth. Default is |
n |
The number of equally spaced points at which the density is to be estimated. When n > 512, it is rounded up to a power of 2 as in the |
tol |
Accuracy requested in the computation of the critical bandwidth. Default value |
display |
Logical, if |
... |
Arguments to be passed to subsequent methods, |
x |
An object inheriting from class |
addplot |
Logical, if |
xlab |
A title for the x axis. See |
ylab |
A title for the y axis. See |
addLegend |
Logical, if |
posLegend |
The vector of two elements of coordinates to be used to position the legend. It can be specified by keyword as in the function |
digits |
Number of significant digits to use, see |
Details
Given a certain number of modes, mod0
, with locmodes
the estimation of the location of modes and antimodes, their density value and the corresponding critical bandwidth is provided. To obtain these estimates, the kernel density estimation with gaussian kernel and the critical bandwidth for mod0
modes is employed. If the compact support is unknown, the critical bandwidth of Silverman (1981) is computed and if such a support is provided, then the one proposed by Hall and York (2001) is calculated. Note that when the support is unknown the critical bandwidth may create artificial modes in the tails.
Since a dichotomy method is employed for computing the critical bandwidth, the parameter tol
is used to determine a stopping time in such a way that the error committed in the computation of the critical bandwidth is less than tol
.
If display=TRUE
, then the kernel density estimation using the critical bandwidth for mod0
modes is plotted. Additionally, the estimated location of modes (dashed lines), antimodes (point lines) and support (solid lines) can be also plotted. If addLegend=TRUE
, a legend (in the position posLegend
) with this information is included.
The NAs will be automatically removed.
Value
A list with class "locmod"
containing the following components:
locations |
Vector with the estimated locations of modes (odd positions of the vector) and antimodes (even positions). |
fvalue |
Vector with estimated density values at modes (odd positions of the vector) and antimodes (even positions). |
cbw |
A list with class |
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.
Hall, P. and York, M. (2001). On the calibration of Silverman's test for multimodality, Statistica Sinica, 11, 515–536.
Silverman, B. W. (1981). Using kernel density estimates to investigate multimodality, Journal of the Royal Statistical Society. Series B, 43, 97–99.
Examples
# Testing for unimodality
set.seed(2016)
data=rnorm(50)
modetest(data)
#There is no evidence to reject the null hypothesis of unimodality
#Estimated location of the mode and its density value
locmodes(data)
## Not run:
#Estimated locations of the five modes in the claw of Marron and Wand (1992)
library(nor1mix)
set.seed(2016)
n<-200
data<-nor1mix::rnorMix(n,MW.nm10)
#Adding the plot of the estimated locations
locmodes(data,5,display=T)
#Assuming that the compact support is [-1.5,1.5]
locmodes(data,5,-1.5,1.5,display=T)
## End(Not run)