geoMean: Weighted geometric mean

Description Usage Arguments Value Examples

View source: R/coin_aggregate.R

Description

Weighted geometric mean of a vector. NA are skipped by default. This function is used inside aggregate().

Usage

1
geoMean(x, w = NULL)

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.

Value

The geometric mean, as a numeric value.

Examples

1
2
3
4
5
6
# a vector of values
x <- 1:10
# a vector of weights
w <- runif(10)
# weighted geometric mean
geoMean(x,w)

COINr documentation built on Nov. 30, 2021, 9:06 a.m.