Description Usage Arguments Details Value Author(s) References See Also Examples
View source: R/half.range.mode.R
For data assumed to be drawn from a unimodal, continuous distribution, the mode is estimated by the “halfrange” method. Bootstrap resampling for variance reduction may optionally be used.
1  half.range.mode(data, B, B.sample, beta = 0.5, diag = FALSE)

data 
A numeric vector of data from which to estimate the mode. 
B 
Optionally, the number of bootstrap resampling rounds to use. Note
that 
B.sample 
If bootstrap resampling is requested, the size of the bootstrap
samples drawn from 
beta 
The fraction of the remaining range to use at each iteration. 
diag 
Print extensive diagnostics. For internal testing only... best left

Briefly, the mode estimator is computed by iteratively identifying
densest half ranges. (Other fractions of the current range can be
requested by setting beta
to something other than 0.5.) A densest half
range is an interval whose width equals half the current range, and
which contains the maximal number of observations. The subset of
observations falling in the selected densest half range is then used to compute
a new range, and the procedure is iterated. See the references for
details.
If bootstrapping is requested, B
halfrange mode estimates are
computed for B
bootstrap samples, and their average is returned
as the final estimate.
The mode estimate.
Richard Bourgon <bourgon@stat.berkeley.edu>
DR Bickel, “Robust estimators of the mode and skewness of continuous data.” Computational Statistics & Data Analysis 39:153163 (2002).
SB Hedges and P Shah, “Comparison of mode estimation methods and application in molecular clock analysis.” BMC Bioinformatics 4:3141 (2003).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31  ## A single normalmixture data set
x < c( rnorm(10000), rnorm(2000, mean = 3) )
M < half.range.mode( x )
M.bs < half.range.mode( x, B = 100 )
if(interactive()){
hist( x, breaks = 40 )
abline( v = c( M, M.bs ), col = "red", lty = 1:2 )
legend(
1.5, par("usr")[4],
c( "Halfrange mode", "With bootstrapping (B = 100)" ),
lwd = 1, lty = 1:2, cex = .8, col = "red"
)
}
# Sampling distribution, with and without bootstrapping
X < rbind(
matrix( rnorm(1000 * 100), ncol = 100 ),
matrix( rnorm(200 * 100, mean = 3), ncol = 100 )
)
M.list < list(
Simple = apply( X, 2, half.range.mode ),
BS = apply( X, 2, half.range.mode, B = 100 )
)
if(interactive()){
boxplot( M.list, main = "Effect of bootstrapping" )
abline( h = 0, col = "red" )
}

Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.