The geometric mean is the nth root of the product of 'n' observations. It multiplies the observations in a set and can be thought of as the exponential of the arithmetic mean of logarithms. We use this definition to create our function. #' The 'geom.mean' function will calculate the mean for all numeric columns in a matrix or data frame.
Details
Because we're using logarithms, our observations must be non-negative. Additionally, by using the geometric mean, SD and variance, we'll be measuring the log-normal dispersion of a log-normal distribution
Examples
d <- rlnorm(60,1,1.4)
geom.mean(d)
#> [1] 2.549775
x <- matrix(rlnorm(60,1,1.3),ncol = 4)
mapply(geom.mean, as.data.frame(x))
#> V1 V2 V3 V4
#> 1.977398 3.462621 6.213770 3.182645