Learn R Programming

LorenzRegression (version 2.2.0)

Gini.coef: Concentration index of y with respect to x

Description

Gini.coef computes the concentration index of a vector y with respect to another vector x. If y and x are identical, the obtained concentration index boils down to the Gini coefficient.

Usage

Gini.coef(
  y,
  x = y,
  na.rm = TRUE,
  ties.method = c("mean", "random"),
  seed = NULL,
  weights = NULL
)

Value

The value of the concentration index (or Gini coefficient)

Arguments

y

variable of interest.

x

variable to use for the ranking. By default \(x=y\), and the obtained concentration index is the Gini coefficient of y.

na.rm

should missing values be deleted. Default value is TRUE. If FALSE is selected, missing values generate an error message

ties.method

What method should be used to break the ties in the rank index. Possible values are "mean" (default value) or "random". If "random" is selected, the ties are broken by further ranking in terms of a uniformly distributed random variable. If "mean" is selected, the average rank method is used.

seed

fixes what seed is imposed for the generation of the vector of uniform random variables used to break the ties. Default is NULL, in which case no seed is imposed.

weights

vector of sample weights. By default, each observation is given the same weight.

Details

The parameter seed allows for local seed setting to control randomness in the generation of the uniform random variables. The specified seed is applied to the respective part of the computation, and the seed is reverted to its previous state after the operation. This ensures that the seed settings do not interfere with the global random state or other parts of the code.

See Also

Lorenz.curve, Lorenz.graphs

Examples

Run this code
data(Data.Incomes)
# We first compute the Gini coefficient of Income
Y <- Data.Incomes$Income
Gini.coef(y = Y)
# Then we compute the concentration index of Income with respect to Age
X <- Data.Incomes$Age
Gini.coef(y = Y, x = X)

Run the code above in your browser using DataLab