Dear readers, my blog has been moved to a new site that is hosted by the University of Minnesota:

"Fiscal Issues and Geeky Stuff"

Thanks for your attention!

## Wednesday, July 2, 2008

### My new blog site

## 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 1978; Shorrocks 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.

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:

## Sunday, June 29, 2008

### Excel2LaTeX: tricks in my Mac

This is the official introduction to Excel2LaTeX (2.0):

- The Visual Basic add-in doesn't work for Mac Excel 2008. You may use Mac Excel 2004 for the purpose.
- I place the downloaded file "Excel2LaTeX.xla" under "/Applications/Microsoft Office 2004/Office/Add-Ins."
- I manually open the xla file once in order for Excel 2004 to recognize the location for the add-in file; only then can I turn on the Excel2LaTeX button under Toolbars.
- After converting a selected area in Excel to LaTeX codes, additional tricks are needed to apply the codes. To use the clipboard function, I have to copy things to TextEdit and then recopy them to TeXShop to get them work -- otherwise, TeXshop is confused with some "invalid character." To use the "Save to File" function, I change "Desktop\Sheet1.text" to ":Desktop\Sheet1.tex" in order to get the file landed correctly in my Desktop.

## 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:

## Tuesday, June 24, 2008

### Archive: Weird computer problems and fixes

1. Excel crashes with an error message "SYLK: File format is not valid" -- Excel cannot open a text or CSV file when the first two characters of the file are the letters ID (uppercase). See the link for more explanations. [06/24/2008]

2. Excel 2004 (Mac) crashed every time I opened it, as it kept opening a corrupted "recovered" file and then quitting automatically. I couldn't solve the problem even after removing and reinstalling Excel. The problem was finally fixed after I deleted "com.microsoft.office.prefs.plist" under "Users/~/Library/Preferences." Later I got to learn that it is a common solution when MS Office crashes. [06/24/2008]

3. Vmware Fusion: Windows XP failed to find shared folders. The fix is simple: go "Start" -->" Run" --> "\\.host" and press enter. [06/24/2008]

## Friday, June 20, 2008

### Recourses about R

Collected resources about R:

- The ultimate source: CRAN
- Download and install: MacOS X, Windows
- To search R-related topics: CRAN-Google
- An Introduction to R: [browse HTML | download PDF]
- R Graphics by Paul Murrell: Example figures with codes

## Tuesday, June 17, 2008

### New partnership between a county and school system

As far as I know, most school districts in North Carolina are not "independent" ones; instead, they get direct funding from county governments along with other sources of revenue. NC school districts however may retain their authorities in education decision-making independent of county governments.