Showing posts with label statistics. Show all posts
Showing posts with label statistics. Show all posts

Tuesday, July 1, 2008

Regression-based inequality decomposition in R

In a previous blog I posted the R functions to decompose Gini coefficients based on a weighted average of pseudo-Gini (Fei et al 1978Shorrocks 1982). Another way to decompose inequality is a regression-based approach proposed by Morduch and Sicular (2002) following the logic of Shorrock's theorem in his classic 1982 paper. 


1. The R function I created


decomp <- function(M) {

    n <- length(M$coefficients)

cov <- cov(M$model[,1],M$model)

var <- cov[1]

cof <- M$coefficients

share <- cov[2:n]*cof[2:n]/cov[1]

decomp <- rbind(cov[2:n],cof[2:n],var,share)

rownames(decomp) <- c("covariance","coefficient",

                      "variance","contribution")

decomp

}


2. An example in R results:


> M <- lm(PCEP2~PCGDP2 + POPDEN + PRIMERT, data=data)
> decomp(M)
                  PCGDP2       POPDEN      PRIMERT
covariance   209.4603179  -0.23886994  -0.69024676
coefficient    0.2973024 -32.81779552 -17.33004045
variance     423.0538678 423.05386785 423.05386785
contribution   0.1471989   0.01852999   0.02827537
> #. A test: The sum of contribution equals to the R square.
> sum(decomp(M)[4,]);summary(M)$r.squared
[1] 0.1940043
[1] 0.1940043

Thursday, June 26, 2008

Calculating decomposition of Gini coefficient in R

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:




An simulated example:




Friday, June 20, 2008

Recourses about R

Collected resources about R:

Friday, June 6, 2008

Spatial data mining in local finance

Data mining is the automatic process of sorting through large amounts of data and discovering patterns. It has been described as "the nontrivial extraction of implicit, previously unknown, and potentially useful information from data" (Frawley et al 1992). For an introduction to data mining, see presentation slides on the website of Professor Robert Stine, from whom I learned the topic at ICPSR

Spatial data ming is the application of data mining techniques to spatial data, with the objective to discover spatial patterns. Still at the early stage of development, spatial data mining is considered a new field with boundaries yet to be defined. In general, spatial data mining focuses more on large data sets and tend to be exploratory in nature, with heavy reliance on newly developed computational powers (Professor Guo). 

In a recent project I am using exploratory spatial data analysis (EDA) to visualize and analyze spatial patterns of inter-local fiscal relations with a comprehensive database that include hundreds of fiscal variables for all local governments in Georgia. This may be an example of spatial data mining in the study of public finance and local government management. I am eager to meet others with similar interests. (Click here to get my presentation slides on ABFM 2007.)

Some resources about spatial data mining: 
  1. Spatial data mining research group in UMN
  2. Spatial data mining @ University of Munich
More to come...

Wednesday, December 19, 2007

Cool graphs for trends in income inequality

Andrew makes some cool graphs showing trends in income inequality within states. The graphs include:
• 50 little graphs for each state, 1963-2004;
• scatterplots of annual % increase vs. state income, for either 10% and 90% percentile;
• Time-trend plot of absolute income and relative income by states;
• Scatterplot of 2000 vs. 1929 avg income, and
• Scatterplot of unadjusted and adjusted avg income, 2000

Graphs like these will be handy in my study of fiscal disparities. So I blog to keep the note.

Tuesday, December 18, 2007

Bayesian methods during the dark ages

Andrew Gelman reviews the second edition of Jeff Gill’s Bayesian book and talks about Bayesian methods during the dark ages.

There was a long time Bayesian methods were consider "while superior in theoretical foundation, led to mathematical forms that were intractable" [citation unknown]. Intractable is as intractable does, says Andrew. Box, Tiao, Stein, Efron, Morris... these statisticians and scientists worked their butt off getting applied Bayesian methods to work before the new computational methods were around and, in doing so, motivated the development of said methods and actually developed some of these methods themselves. Then it comes Gibbs sampling which took the methods to the next level: more people could use the methods with less training, and the experts could fit more sophisticated methods.

Monday, December 17, 2007

Taxing the tall

One of the 70 ideas covered by The New York Times Magazine "Year In Ideas" is Mankiw & Weinzierl’s intentionally quirky proposal of taxing tall people, based on the empirical distribution of height and wages.

The topic has attracted lots of attention from some famous bloggers, including tall political scientist David Park, tall economist Robin Hansen, and not-so-tall political scientists/statistician Andrew Gelman.

All share the same opinion that the tax is “wacky,” but Andrew’s argument is most interesting to me. In the first place, he points out that height isn't actually correlated very much with income -- together, height and sex predict earnings with an R-squared of only 9%. More importantly, however, it is the big “Huh?” that he makes towards Mankiw and Weinzierl’s argument that height should not be taxed as it is a ‘justly acquired endowment.’

“... who ever said that you can only tax something that was ‘unjustly wrestled from someone else’?” Even if we can imagine a society with on unjust wrestling at all, the tax money needs to come from somewhere, he argues.

The concluding remarks: “Maybe this is a difference between how economists and political scientists view the world. Mankiw and Weinzierl seem to view taxes as a way to punish people, whereas I see taxes as a way to raise money?”