This function computes the efficiency as the square of the coefficient of variation.
See the Details section below for further information.
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.
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.
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