sgm: Geometric mean

sgmR Documentation

Geometric mean

Description

This function computes the sample geometric mean.

Usage

sgm(x, na.rm = FALSE)

Arguments

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.

Details

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

x

the values in a sample

n

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."

Value

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).

Author(s)

Irucka Embry

References

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.

See Also

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.

Examples


# 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)




iemisc documentation built on Sept. 25, 2023, 5:09 p.m.