geomean: Classical geometric mean

geomeanR Documentation

Classical geometric mean

Description

Classical geometric mean

Usage

geomean(x, na.rm = TRUE, naValue = NA, offset = 0, ...)

Arguments

x

numeric vector containing only positive values

na.rm

logical indicating whether to ignore NA values. Note that NA values are removed prior to log-transformation, to avoid negative numbers being dropped completely. To drop negative numbers, do so prior to calling geomean().

offset

numeric value added to input x prior to log transformation, intended only when values between 0 and 1 should be retained. Note that the offset makes the result slightly different than classical geometric mean.

...

additional parameters are ignored.

Details

This function calculates the classical geometric mean.

The classical geometric mean is defined as the exponentiated mean of log-transformed values. Said another way, it is the nth root of the product of n numeric values. This formula is analogous to geometric distance. The formula does not allow negative values, however, and if any value is zero the result is also zero.

Value

numeric value representing the geometric mean of input values

See Also

Other jam numeric functions: jamGeomean()

Examples

x <- c(2, 4);
geomean(x);

x <- c(-2, 2, 4);
geomean(x);

x <- c(0, 4000, 200000);
geomean(x);


jmw86069/jambio documentation built on April 21, 2024, 2:48 p.m.