Skip to contents

This function computes the efficiency as the square of the coefficient of variation.

See the Details section below for further information.

Usage

efficiency(x, g = NULL, na.rm = TRUE)

Arguments

x

numerical vector.

g

(optional) vector or factor object giving the group for the corresponding elements of x.

na.rm

logical indicating whether missing values should be removed before computation.

Value

A numerical value or a vector containing the computed measure per class.

Details

The efficiency is a measure of dispersion. It is here defined as the square ratio of the standard deviation to the mean:

$$ EFFICIENCY = (\frac{standard deviation}{mean})^2 = \frac{\sigma^2}{\mu^2}$$

If x can be partitioned into \(c\) subgroups (provided by g), then the \(EFFICIENCY\) is computed for each class.

References

https://en.wikipedia.org/wiki/Efficiency_(statistics)#Estimators_of_u.i.d._Variables

Author

Alessandro Barberis

Examples

#Seed
set.seed(1010)

#Define size
n = 10

#Data
x = sample.int(n = 100, size = n, replace = TRUE)

#Grouping variable
g = c(rep("a", n/2), rep("b", n/2))

#Efficiency
efficiency(x)
#> [1] 0.2039627

#Efficiency by group
efficiency(x = x, g = g)
#>          a          b 
#> 0.47507182 0.03704986