Classical geometric mean
Arguments
- x
numericvector containing only positive values- na.rm
logicalindicating whether to ignoreNAvalues, default TRUE. When TRUE, NA values are removed upfront, before log transformation. Note that negative values are maintained by default, by applying log transformation on the absolute value, then multiplying by the sign.- offset
numericvalue added to inputxprior 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 original formula does not permit negative values, however
the formula used here applies log to the absolute value,
then multiplies that by the sign. For example x(-4, 1/4)
would be applied log2(abs(c(-4, 1/4))) * sign(c(-4, 1/4))
and thus both values would become -2. This adaptation is for
convenience, assuming that a fraction 1/4 and negative value
-4 represent the same underlying value, usually a
fold change. A fold change may be represented either as -4`` or as 1/4“, although technically the 1/4 is not a fold
change but a ratio.
Whens supplying non-negative values, specifically those where
a value '0' should be considered a legitimate measured
result, and therefore should be incorporated into the geomean,
set argument 'offset' to some suitable offset, most
common is offset=1 to mimic log2(1 + x) transformation.
See also
Other Internal utility functions:
combineGRcoverage(),
compressPolygonM(),
df2colorSub(),
dfWide2segments(),
escapeWhitespaceRegexp(),
factor2label(),
intercalate(),
internal_junc_score(),
jamGeomean(),
list2im(),
shrinkMatrix(),
simplifyXY(),
stackJunctions(),
strsplitOrdered()