Calculate weighted versions of the Gini and Inoua (2021) indexes as originally defined in the econometric literature, using the half mean relative distance method.

dispersionIndex(
  x,
  index = "gini",
  w = rep(1, length(x)),
  weight.mean = TRUE,
  inverse = FALSE,
  max.cross = .Machine$integer.max,
  pb = FALSE
)

gini(...)

inoua(...)

Arguments

x

A vector of values

index

A character string, either 'gini', or 'inoua', representing whether distances are calculated in L1 or L2 space, respectively

w

A vector of weights with the same length as x

weight.mean

Logical. Should the mean values be weighted, or does the global depend exclusively on the observations? Default is TRUE.

inverse

Logical. Should the value for the inverse weights be calculated as well using binary decomposition? Default is FALSE. This rarely makes sense if the weights are population-based, but it does if they're probability-based.

max.cross

When processing, what is the maximum number of rows that an internal data.table can have? This is generally not a concern unless the number of observations approaches sqrt(.Machine$integer.max)--usually about 2^31 for most systems. Lower values result in a greater number of chunks thus allowing larger data.sets to be calculated

pb

Logical. Should a progress bar be displayed? Default is FALSE, although if a large dataset is processed that requires adjusting max.cross this can be useful

...

Parameters to pass on to dispersionIndex.

Value

A numeric of length 1 (if inverse = FALSE) or 2 (if inverse = TRUE) representing the requested index.

References

Inoua, Sabiou (2021). "Beware the Gini Index! A New Inequality Measure." ESI Working Paper 21-18, https://digitalcommons.chapman.edu/esi_working_papers/355/.

Examples


# Generate dummy observations
x <- runif(10, 1, 100)
n <- runif(10, 0, 10)

# Calculate Gini index
gini(x)
#>      Gini 
#> 0.3163817 

# Calculate weighted Inoua index
inoua(x, w = n)
#>   Inoua 
#> 0.33126