logmean | R Documentation |
Compute the log-average or geometric mean of a numeric vector
logmean(x, na.rm = FALSE)
logMeanPlusSD(x, na.rm = FALSE)
logMedianPlusSD(x, na.rm = FALSE)
x |
numeric vector of positive values |
nSD |
numeric scalar, the number of standard deviations to add |
Implements the geometric mean, by log transforming the values in x
, calculating
that mean, and then exponentiating the result. This has better numerical stability then
then using the N-th root of the power series of x
.
The 'PlusSD' forms are used to thresholds of statistical significance, by adding an
arbitrary number of standard deviation of log(x)
, to the calculation.
As log transform is undefined for zeros and negative values, some level of data cleaning is implemented to tolerate invalid data. Specifically, negatives are set to NA and thus ignored. If all values are zero, zero is returned. If a subset of values are zero, they are replaced with the smallest non-zero value prior to log transform and averaging.
a numeric scalar
Contrast with mean
and sqrtmean
.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.