![]() |
PING
0.9
Statistical data handling and processing in production environment
|
Compute the Gini index of a set of observations.
dsn : a dataset reference with continuous observations;var : variable of the input dataset dsn on which the Gini index will be computed;weight : (option) weight (frequencies), either a variable in dsn to use to weight the values of var, or a constant value; default: weight=1, i.e. it is not used;method : (option) method used to compute the Gini index; it can be: LAEKEN, or CANONICAL; default: LAEKEN, i.e. the formula used for computing the Gini index (which is 100* Gini coefficient) as: gini = 100 * (( 2 * swtvarcw - swt2var ) / ( swt * swtvar ) - 1)
issorted : (option) boolean flag (yes/no) set when the input data is already sorted; default: issorted=no, and the input will be sorted;lib : (option) name of the input library; by default: empty, i.e. WORK is used._gini_ : name of the macro variable storing the value of the Gini index.
Considering the following datasets gini10_1:
| Obs | x |
|---|---|
| A | 2 |
| A | 2 |
| A | 2 |
| B | 3 |
| B | 3 |
and gini10_2;
| Obs | x | w |
|---|---|---|
| A | 2 | 3 |
| B | 3 | 2 |
both calls to the macro:
actually return the Gini index: gini=10.
Run macro %_example_gini for examples.
The default LAEKEN method implements the approach of Alfons & Templ. In short, this means that the macro %gini runs the following DATA step over already sorted data: