Calculates the harmonic mean and its confidence interval of a vector x.
Arguments
- x
a positive numeric vector. An object which is not a vector is coerced, if possible, by
as.vector().- conf.level
confidence level of the interval. If set to
NA(the default), only the point estimate is returned.- sides
character string specifying the sidedness of the confidence interval (one of
"two.sided"(default),"left"or"right"). SeeConfidenceIntervals().- method
a vector of character strings representing the type of intervals required. The value should be any subset of the values
"classic","boot". Seeboot::boot.ci().- na.rm
logical, indicating whether
NAvalues should be stripped before the computation proceeds. Defaults toFALSE.- ...
further arguments are passed to the
boot::boot()function. Supported arguments aretype("norm","basic","stud","perc","bca"),paralleland the number of bootstrap replicatesR. If not defined those will be set to their defaults, being"basic"fortype, option"boot.parallel"(and if that is not set,"no") forparalleland999forR.
Value
if conf.level = NA, a numeric scalar. Otherwise a named
numeric vector with elements:
estpoint estimate of the harmonic mean
lcilower confidence interval bound
uciupper confidence interval bound
Details
To compute the harmonic mean, 1/x is first calculated, before the
arithmetic mean and its confidence interval are computed by
lumen::meanCI(). The harmonic mean is then the reciprocal of the
arithmetic mean of the reciprocals of the values. The same applies to the
confidence interval.
The harmonic mean is restricted to strictly positive inputs. Non-positive
values are turned into NA and therefore make the result NA
unless na.rm = TRUE, in which case they are dropped. If the lower
bound of the confidence interval is not greater than zero, then the
confidence interval is not defined, and thus NA will be reported.
sides names the side on which the finite bound lies: "left"
yields an interval bounded below, "right" one bounded above. The
harmonic mean of positive values is itself positive, so the open lower
side is reported as 0 rather than as NA or \(-\infty\).
Use sapply() to calculate the measures from data frame, resp.
from a matrix.
References
Snedecor, G. W., Cochran, W. G. (1989) Statistical Methods, 8th ed. Ames, *IA: Iowa State University Press *
See also
Other location:
gmean(),
hodgesLehmann(),
huberM(),
meanX(),
medianX(),
modeX(),
tukeyBiweight()
