This function provides the mode forest.
modeforest(data,bws=NULL,gridsize=NULL,B=99,n=512,cbw1=NULL,cbw2=NULL,
display=TRUE,logbw=FALSE,from=NULL,to=NULL,xlab=NULL,ylab=NULL)
Sample in which the mode forest is computed.
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 grid points in the horizontal (values of the variable, first element) and vertical (bandwidths, second element) axis. Default is c(100,151)
.
Number of replicates used for generating the mode forest. Default B=99
.
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
.
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.
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.
Logical, if TRUE
the mode tree plot is plotted. Default TRUE
.
Logical, if TRUE
the plot displays and returns the log10 bandwidths. Default logbw=FALSE
.
First plotted value of the variable. Default is below the data minimum.
Last plotted value of the variable. Default is above the data maximum.
A title for the x axis. See title
.
A title for the y axis. See title
.
Matrix including the percentage of times that a mode tree falls in each location-bandwidth pixel.
Employed location values to represent the mode forest.
Employed bandwidths to compute the different mode trees.
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
. 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.
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.
# NOT RUN {
#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")
# }
Run the code above in your browser using DataLab