This function computes the number of modes in a kernel density estimator using the Gaussian kernel and a given bandwidth parameter.
nmodes(data,bw,lowsup=-Inf,uppsup=Inf,n=2^15,full.result=F)
Sample for computing a kernel density estimator and determine the number of modes.
Bandwidth parameter for kernel density estimation.
Lower limit for the random variable support. Just the number of modes greater than lowsup
are taken into account. Default is -Inf
.
Upper limit for the random variable support. Just the number of modes greater than lowsup
are taken into account. Default is Inf
.
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 density
function. Default n=2^15
.
If this argument is TRUE then it returns the full result list, see below. Default full.result=FALSE
.
Depending on full.result
either a number, the number of modes for the bandwidth provided in bw
, or an object of class "estmod"
which is a list
containing the following components:
The number of modes for the bandwidth provided in bw
.
The number of non-missing observations in the sample used for computing the number of modes.
Employed bandwidth for kernel density estimation.
Lower limit of the support where the number of modes are computed.
Upper limit of the support where the number of modes are computed.
The n
coordinates of the points where the density is estimated for computing the number of modes.
The estimated density values.
The number of modes in the interval provided by lowsup
and uppsup
is computed. For this calculation, a kernel density estimator with Gaussian kernel and bandwidth bw
is used.
The NAs will be automatically removed.
Ameijeiras-Alonso, J., Crujeiras, R.M. and Rodr<U+00ED>guez-Casal, A. (2021). multimode: An R Package for Mode Assessment, Journal of Statistical Software, 97, 1--32.
# NOT RUN {
# Number of modes in the interval (-1.5,1.5), using the bandwidth 0.5.
set.seed(2016)
data=rnorm(50)
nmodes(data,0.5,-1.5,1.5)
# }
Run the code above in your browser using DataLab