I'm working on calculating the GINI coefficient in R to analyze various aspects of wealth inequality. Specifically, I am interested in decomposing GINI by different subgroups. However, my data includes zero and negative values, and I haven't discovered an R package capable of handling these. In contrast, Stata has a package called INEQDEC0 that accounts for these values. Does anyone know of an equivalent package in R?
Asked
Active
Viewed 24 times
1 Answers
0
Please have a look on wINEQ package. Looks it works with 0 and negative values:
wINEQ::Gini(X= c(1:10))
#> [1] 0.3
wINEQ::Gini(X= c(-10:1))
#> [1] -0.441358
wINEQ::Gini(X= c(10, 2, -10, -7, 0, 0))
#> [1] -4.233333
wINEQ::Gini(X= c(-10:10))
#> [1] NaN
Created on 2024-01-13 with reprex v2.0.2
The last NaN result is caused by median value of c(-10:10) which is 0 and it's used in denominator of gini cooeficient.
Grzegorz Sapijaszko
- 266
- 1
- 6
-
Thanks for the answer, i am specifically interested in decomposing the inequality of GINI by subgroups. The package you suggested, while great, it does make the decomposition by subgroups – Jack Jan 15 '24 at 10:12
svygei? – Anthony Damico Jan 16 '24 at 20:23