Decomposing Gini coefficient in R (updated)
I am working on several projects on fiscal disparities. The level of inequality can be measured by summary indices such as the Gini coefficient, but I like to move a step forward and decompose the aggregate inequality value into its relevant component contributions.
Take income inequality as an example. One way of factor decomposition is to separate the effects of multiple income streams that form the total income. It has been proposed that a Gini coefficient can be separated as multiple components based on a weighted average of pseudo-Gini (Fei et al 1978; Shorrocks 1982). With this method, for each revenue stream, we can calculate its absolute contribution, relative contribution, and marginal effect (Lerman and Yitzhaki 1985) to the inequality (Gini) of total income.
How to do this in R? Failed to find any package ("library") that can do it directly, I decided to create the function on my own by revising R codes from known packages such as ineq and reldist. It turns out to be easy and really fun!
The formulas (R file):
The R outputs are shown below: