modetree: Mode tree

Description Usage Arguments Details Value Author(s) References Examples

View source: R/graphical_tools_lin.R

Description

This function provides the mode tree.

Usage

1
2
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.

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 gridsize=c(512,151).

cbw1

Number of modes for which the first critical bandwidth is calculated. This is the first bandwidth used to compute the mode tree when bws is not specified.

cbw2

Number of modes for which the second critical bandwidth is calculated. This is the last bandwidth used to compute the mode tree when bws is not specified.

display

Logical, if TRUE the mode tree plot is plotted. Default TRUE.

logbw

Logical, if TRUE the plot displays and returns the log10 bandwidths. Default logbw=FALSE.

logbw.regulargrid

Logical, if TRUE a regular grid of bandwidths is created over the log10 scale. Default logbw.regulargrid=FALSE.

...

Arguments to be passed to subsequent methods, plot.gtmod for the plot, print and summary 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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
#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)

Example output

Call:
	 modetree(data = data, bws = c(0.2, 0.5))

n=50. Location values range: -2.791471  2.19422
Number of employed bandwidths: 151. log10 bandwidths scale: FALSE
Bandwidths range:      0.2      0.5

Warning message:
In modetree(data, bws = c(0.2, 0.5)) :
  A grid of 'bws' between the given ones were used

Call:
	 modetree(data = data, cbw1 = 1, cbw2 = 8)

n=200. Location values range: -2.791471  2.19422
Number of employed bandwidths: 151. log10 bandwidths scale: FALSE
Bandwidths range: 0.1172104 0.3068695

multimode documentation built on March 21, 2021, 1:06 a.m.