sgm | R Documentation |
This function computes the sample geometric mean.
sgm(x, na.rm = FALSE)
x |
numeric vector that contains the sample data points (any negative values will be ignored). |
na.rm |
logical vector that determines whether the missing values should be removed or not. |
Geometric mean is expressed as
\bar{x}_g = \left(x_{1}x_{2} \cdots x_{n}\right)^{\frac{1}{n}}
\bar{x}_g
the sample geometric mean
the values in a sample
the number of positive values
"The geometric mean is used in averaging values that represent a rate of change. It is the positive nth root of the product of the n values."
sample geometric mean as a numeric vector. The default choice is
that any NA values will be kept (na.rm = FALSE
). This can be
changed by specifying na.rm = TRUE
, such as sgm(x, na.rm = TRUE)
.
Irucka Embry
Nathabandu T. Kottegoda and Renzo Rosso, Statistics, Probability, and Reliability for Civil and Environmental Engineers, New York City, New York: The McGraw-Hill Companies, Inc., 1997, page 13.
mean
for arithmetic mean
shm
for harmonic mean, cv
for coefficient of
variation (CV), relerror
for relative error, approxerror
for
approximate error, rms
for root-mean-square (RMS), and ranges
for sample range.
# Example 1.13 from Kottegoda (page 13)
library(iemisc)
city_pop <- c(230000, 310000)
sgm(city_pop)
# Compare the geometric mean to the arithmetic mean
mean(city_pop)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.