Oaxaca decomposition in R

I would like to decompose Oaxaca into R. It is used, for example. I believe that labor economics distinguishes explained variance compared to inexplicable variance. I could not find a suitable solution in R, and I am rather reluctant to create it (I would probably mess it up).

In any case, the procedure is briefly explained here:

http://en.wikipedia.org/wiki/Ronald_Oaxaca

Stata is blessed with a pretty good package for this, but Stata is not easy for me.

www.stata.com/meeting/5german/SINNING_stata_presentation.pdf

Please note: I also posted a message about R-help, but it did not receive a response. Hope this list is good too.

Thanks in advance, Rasmus

Edit: I made the following function, which seems to give incorrect answers (urgh). I tried to follow the Stata link above, but it did not work as I hoped :)

oaxaca <- function (fsex,frace1,frace2) { ## First we make regresions data1 <- subset(l2,sex==fsex & race==frace1) data2 <- subset(l2,sex==fsex & race==frace2) mindata1 <- subset(cbind(grade,exp,I(exp^2)),sex==fsex & race==frace1) mindata2 <- subset(cbind(grade,exp,I(exp^2)),sex==fsex & race==frace2) reg1 <- lm(log(wage)~grade+exp+I(exp^2), data=data1) reg2 <- lm(log(wage)~grade+exp+I(exp^2), data=data2) ## DECOMPOSITION ################ ## Variables gap <- mean(log(wage[race==frace1 & sex==fsex]))-mean(log(wage[race==frace2 & sex==fsex])) mean1 <- colMeans(mindata1) mean2 <- colMeans(mindata2) beta1 <- summary(reg1)$coefficients[,1] beta2 <- summary(reg2)$coefficients[,1] beta1incep <- summary(reg1)$coefficients[1,1] beta2incep <- summary(reg2)$coefficients[1,1] beta1coef <- summary(reg1)$coefficients[c(2,3,4),1] beta2coef <- summary(reg2)$coefficients[c(2,3,4),1] betastar <- .5*(beta1coef+beta2coef) betastar2 <- (beta1+beta2)/2 expl <- sum((mean1-mean2)*beta1coef) uexpl <- sum(mean2*(beta2coef-beta1coef)) pct=expl/gap pct2=uexpl/gap ## output out <- data.frame(Gap=gap, Explained=expl, Unexplained=uexpl, Pct=pct*100) return(out) } 
+7
r stata economics
source share
2 answers

I used Oaxaca type expansions. I did not find any packages for R, so I wrote several functions that do this. This is similar to the corresponding package in Stata.

You can find a copy of it at : https://github.com/eyjo/Oaxaca

Please note that at that time I was interested in using models with fixed effects (panel data) that are not directly compatible with these decompositions. For models like FE, there is an incomplete handler, but it should not be used. I wanted to create a package from it, but I did not find it.

+7
source share

The oaxaca CRAN package can evaluate Blinder-Oaxaca decompositions for linear models, as well as create histograms that show results: http://cran.r-project.org/web/packages/oaxaca/index.html

It can also calculate boot standard errors to see how vague the estimate is.

The vignette provides a detailed description of the features of the package, and also provides some examples of its use. See Here: " oaxaca: Decomposition of Blinder-Oaxaca in R "

+4
source share

All Articles