modetree {multimode} | R Documentation |
Mode tree
Description
This function provides the mode tree.
Usage
modetree(data,bws=NULL,gridsize=NULL,cbw1=NULL,cbw2=NULL,display=TRUE,
logbw=FALSE,logbw.regulargrid=NULL,...)
Arguments
data |
Sample in which the mode tree is computed. |
bws |
Vector or range of bandwidths. If it is a vector of size two, then it is used a grid of bandwidths between the given values. Default lower bandwidth is twice the distance between the grid points used for estimating the density and upper bandwidth equal to the range of the data. Unless it is specified a vector of size greater than two, the number of bandwidths employed is equal to the second element of |
gridsize |
Number of equally spaced points at which the density is to be estimated (first element) and bandwidths used to compute the mode tree (second element). Default is |
cbw1 |
Number of modes for which the first critical bandwidth is calculated. This is the first bandwidth used to compute the mode tree when |
cbw2 |
Number of modes for which the second critical bandwidth is calculated. This is the last bandwidth used to compute the mode tree when |
display |
Logical, if |
logbw |
Logical, if |
logbw.regulargrid |
Logical, if |
... |
Arguments to be passed to subsequent methods, |
Details
The mode tree for the sample given in data
is computed. For this calculation, a kernel density estimator with Gaussian kernel and bandwidths bws
is used. When it is plotted, it shows with the continuous lines the estimated mode locations at each bandwidth. The horizontal dashed lines indicate the splitting of a mode in more modes.
The NAs will be automatically removed.
Value
A list with class "gtmod"
containing the following components:
locations |
Estimated mode locations for the bandwidths given in the row names. |
range.x |
The data range, employed to represent the mode tree. |
range.bws |
Employed bandwidths to compute the mode tree. |
logbw |
Logical value indicating if the bandwidths are given in the log10 scale. |
sample.size |
The number of non-missing observations in the sample used for obtaining the mode tree. |
call |
The unevaluated expression, which consists of the named function applied to the given arguments. |
Author(s)
Jose Ameijeiras-Alonso, Rosa M. Crujeiras and Alberto RodrÃguez-Casal
References
Minnotte, M. C. and Scott, D. W. (1993). The mode tree: A tool for visualization of nonparametric density features, Journal of Computational and Graphical Statistics, 2, 51–68.
Examples
#Mode tree using a grid of bandwidths between 0.2 and 0.5
set.seed(2016)
data=rnorm(50)
modetree(data,bws=c(0.2,0.5))
## 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)
#Mode tree between the critical bandwidths for 1 and 8 modes
modetree(data,cbw1=1,cbw2=8)
abline(v=1.5);abline(v=-1.5)
## End(Not run)