modeforest: Mode forest

Description Usage Arguments Details Value Author(s) References Examples

View source: R/graphical_tools_lin.R

Description

This function provides the mode forest.

Usage

1
2
modeforest(data,bws=NULL,gridsize=NULL,B=99,n=512,cbw1=NULL,cbw2=NULL,
display=TRUE,logbw=FALSE,from=NULL,to=NULL,logbw.regulargrid=NULL,...)

Arguments

data

Sample in which the mode forest 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 grid points in the horizontal (values of the variable, first element) and vertical (bandwidths, second element) axis. Default is c(100,151).

B

Number of replicates used for generating the mode forest. Default B=99.

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 density function. Default n=512.

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.

from

First plotted value of the variable. Default is below the data minimum.

to

Last plotted value of the variable. Default is above the data maximum.

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 forest for the sample given in data is computed. For this calculation, a kernel density estimator with Gaussian kernel and bandwidths bws is used. The mode forest is generated by looking simultaneously at a collection of mode trees generated by the original sample and B random resamples drawn with replacement from data. When the mode forest is plotted, this tool represents the number of times an estimated mode falls in each location-bandwidth (horizontal-vertical axis) pixel. The pixels are then shaded proportionally to counts (large counts corresponding to darker pixels and low counts to lighter ones).

The NAs will be automatically removed.

Value

A list with class "gtmod" containing the following components:

modeforest

Matrix including the percentage of times that a mode tree falls in each location-bandwidth pixel.

range.x

Employed location values to represent the mode forest.

range.bws

Employed bandwidths to compute the different mode trees.

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 forest.

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., Marchette, D. J. and Wegman, E. J. (1998). The bumpy road to the mode forest, Journal of Computational and Graphical Statistics, 7, 239–251.

Examples

1
2
3
4
5
6
#Mode forest using a grid of bandwidths between 0.2 and 0.5 and 29 bootstrap replicas
set.seed(2016)
data=rnorm(50)
modeforest(data,bws=c(0.2,0.5),B=29)
#Original mode tree for this sample
modetree(data,bws=c(0.2,0.5),addplot=TRUE,col.lines="red")

Example output

Call:
	 modeforest(data = data, bws = c(0.2, 0.5), B = 29)

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

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

Call:
	 modetree(data = data, bws = c(0.2, 0.5), addplot = TRUE, col.lines = "red")

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), addplot = TRUE, col.lines = "red") :
  A grid of 'bws' between the given ones were used

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