View Zhirong Zhao's profile on LinkedIn

Blogroll

My pages

Visitors

Powered by

UThinkrunning MT v.4.25

Header image of Hong Kong financial center courtesy of hleung on flickr.

Gini Decomposition by Revenue Sources with R

In working on a fiscal disparity project, I defined a function in R to calculate the standard decomposition of Gini coefficient by revenue sources. With two variables -- total income x and a income source x1 -- the standard output includes the Gini coefficient of x, Pseudo Gini of x1, absolute and relative contributions for x1, and the marginal effect of x1 on the Gini coefficient of x.

For technical notes of the standard decomposition, see Fei et al 1978, Shorrocks 1982, and Lerman and Yitzhaki 1985. In particular, Fei et al 1978 outlined the basic logic of inequality decomposition; Shorrocks 1982 explained the Pseudo Gini, and Lerman and Yitzhaki 1985 provided the surprisingly simple way to estimate the marginal effect.

The R codes are:
---- ----
dec.gini <- function(x,x1) {
                        # preparation                
                
n <- length(x); o <- order(x)
                
y <- cbind(x[o],x1[o])
                        # Gini
                
G1 <- sum(y[,1]*1:n)
                
G1 <- 2*G1/(n*sum(y[,1]))
                
G1 <- G1 - 1 - (1/n)
                        # Pseudo Gini
                
G2 <- sum(y[,2]*1:n)
                
G2 <- 2*G2/(n*sum(y[,2]))
                
G2 <- G2 - 1 - (1/n)
                        # Contribution
                
F1 <- G2*sum(y[,2])/sum(y[,1])
                
F2 <- F1/G1        
                MG <- F2-sum(y[,2])/sum(y[,1])
                        # Marginal effect
                
out <- rbind(G1,G2,F1,F2,MG)
                
rownames(out) <- c("Gini","Pseudo Gini",
                                
"Contribution","Rel. Contribution",
                                
"Marginal Effect")
                
out
                }

An example with two hypothetical variables, “Income” and “Tip” (a subset of “Income”).
---- ----


Picture.jpg

Post a comment

Hubert H. Humphrey Institute of Public Affairs