[R] conditional weighted quintiles

Ozan Bakis abakis at gmail.com
Mon Jan 19 05:03:42 CET 2009


Dear All,

I am economist and working on poverty / income inequality.  I need descriptive
statitics like the ratio of education expentitures between different income
quintiles where each household has a different weight. After a bit of
google search I found 'Hmisc' and 'quantreg' libraries for weighted quantiles.

The problem is that these packages give me only weighted quintiles; but what
I need is conditional weighted quintiles. The below example illustrates
what I mean.

x <- data.frame("id"=c(1:5),"income"=c(10,10,20,30,50),
                "education"=c(0,5,5,0,0),"weight"=c(3,2,3,1,1))
x
library(Hmisc)
wtd.quantile(x$income,weights=x$weight)
wtd.quantile(x$education,weights=x$weight)

I would like to see the expenditure of each quintile conditional on income, i.e.
the education expenditures of the 5th quintile equal to zero.

Thanks in advance,
-- 
ozan bakis
   --__--__--




More information about the R-help mailing list