Weighted generalised mean of a vector. NA are skipped by default.
Usage
a_genmean(x, w = NULL, p)
Value
Weighted harmonic mean, as a numeric value.
Arguments
x
A numeric vector of positive values.
w
A vector of weights, which should have length equal to length(x). Weights are relative
and will be re-scaled to sum to 1. If w is not specified, defaults to equal weights.
where p is a coefficient specified in the function argument here. Note that:
For negative p, all x values must be positive
Setting p = 0 will result in an error due to the negative exponent. This case
is equivalent to the geometric mean in the limit, so use a_gmean() instead.