# sgm: Geometric mean In iemisc: Irucka Embry's Miscellaneous Functions

## Description

This function computes the sample geometric mean.

## Usage

 1 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 = ≤ft(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).

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

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.
 1 2 3 4 5 6 7 library(iemisc) # Example 1.13 from Kottegoda (page 13) city_pop <- c(230000, 310000) sgm(city_pop) # Compare the geometric mean to the arithmetic mean mean(city_pop)