shorth {genefilter} | R Documentation |
Calculate the midpoint of the shorth
shorth(x, na.rm=FALSE, tie.action="mean", tie.limit=0.05)
x |
Numeric |
na.rm |
Logical. If TRUE , then NA values are ignored. |
tie.action |
Character scalar. See details. |
tie.limit |
Numeric scalar. See details. |
The shorth is the shortest interval that covers half of the
values in x
. Its midpoint is the median of the data values
that lie in the shorth and can be used as an
estimator of the mode of the distribution that generated x
.
If there are multiple shortest intervals,
the action specified in ties.action
is applied.
Allowed values are mean
(the default), max
and min
.
For mean
, the average value is considered; however, an error is
generated if the start indices of the different shortest intervals
differ by more than the fraction tie.limit
of length(x)
.
For min
and max
, the left-most or right-most, respectively, of
the multiple shortest intervals is considered.
The midpoint of the short of x
.
Wolfgang Huber http://www.ebi.ac.uk/huber, Ligia Pedroso Bras
x <- c(rnorm(500), runif(500) * 10) res <- c(mean=mean(x), median=median(x), shorth=shorth(x)) if(interactive()) { colors = c(1,2,4) hist(x, 40, col="orange") abline(v=res, col=colors, lwd=3) legend(6, 100, names(res), col=colors, lwd=3) }