Geometric Mean and Standard Deviation
Calculates the geometric mean, its confidence interval and the geometric standard deviation of a vector x.
Gmean(x, method = c("classic", "boot"), conf.level = NA, sides = c("two.sided","left","right"), na.rm = FALSE, ...) Gsd(x, na.rm = FALSE)
x |
a positive numeric vector. An object which is not a vector is coerced (if possible) by as.vector. |
method |
a vector of character strings representing the type of intervals required. The value should be any subset of the values |
conf.level |
confidence level of the interval. Default is |
sides |
a character string specifying the side of the confidence interval, must be one of |
na.rm |
logical, indicating whether |
... |
further arguments are passed to the |
To compute the geometric mean, log(x)
is first calculated, before the arithmetic mean and its confidence interval are computed by MeanCI
.
So the geometric mean and geometric sd are restricted to positive inputs (because otherwise the answer can have an imaginary component). Hence if any argument is negative, the result will be NA
. If any argument is zero, then the geometric mean is zero.
The geometric mean is defined as
(x_1 * x_2 * ... * x_n)^(1/n)
and its confidence interval is given as exp(MeanCI(log(x)))
.
Use sapply
to calculate the measures from data frame, resp. from a matrix.
a numeric value.
Andri Signorell <andri@signorell.net>
Snedecor, G. W., Cochran, W. G. Cochran (1989) Statistical Methods, 8th ed. Ames, IA: Iowa State University Press
x <- runif(5) Gmean(x) m <- matrix(runif(50), nrow = 10) apply(m, 2, Gmean) sapply(as.data.frame(m), Gmean)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.