Hi there, I am trying to compute Gini coefficients for vectors containing income classes. The data I possess look loke this: yit <- c(135, 164, 234, 369) piit <- c(367, 884, 341, 74 ) where yit is the vector of income classes, and fit is the vector of associated frequencies.(This data is from Rustichini, Ichino and Checci (Journal of Public Economics, 1999) ). In ineq pacakge, Gini( ) doesn't seem to handle frequencies. On the other had, Lc() compute the Lorenz curve using these frequencies, but I don't manage to use its output to compute the Gini coefficient. I wonder if you have already writen some function to do this, or if you could shed some light here and help me. Thank you very much, Dimitri Szerman [[alternative HTML version deleted]] _______________________________________________________ Instale o discador agora! http://br.acesso.yahoo.com/
On 6/24/05, Dimitri Joe <dimitrijoe at yahoo.com.br> wrote:> Hi there, > > I am trying to compute Gini coefficients for vectors containing income classes. The data I possess look loke this: > > yit <- c(135, 164, 234, 369) > piit <- c(367, 884, 341, 74 ) > > where yit is the vector of income classes, and fit is the vector of associated frequencies.(This data is from Rustichini, Ichino and Checci (Journal of Public Economics, 1999) ). In ineq pacakge, Gini( ) doesn't seem to handle frequencies. On the other had, Lc() compute the Lorenz curve using these frequencies, but I don't manage to use its output to compute the Gini coefficient. I wonder if you have already writen some function to do this, or if you could shed some light here and help me. >Assuming x and n as in the args to Lc, use Brown's formula: with(Lc(x,n), 1 - sum(diff(p) * (L[-1] + L[-length(L)]))) or equivalently: with(Lc(x,n), 1 - sum(c(0,diff(p),0) * (c(L,0) + c(0,L)))) See http://en.wikipedia.org/wiki/Gini_coefficient and the online inequality calculator which can be used to double check results: http://www.poorcity.richcity.org/calculator.htm
On Fri, 24 Jun 2005, Dimitri Joe wrote:> Hi there, > > I am trying to compute Gini coefficients for vectors containing income classes. The data I possess look loke this: > > yit <- c(135, 164, 234, 369) > piit <- c(367, 884, 341, 74 ) > > where yit is the vector of income classes, and fit is the vector of > associated frequencies.(This data is from Rustichini, Ichino and Checci > (Journal of Public Economics, 1999) ). In ineq pacakge, Gini( ) doesn't > seem to handle frequencies.Yeah, this is on our todo list, it would also be nice to support interval data. Hopefully we'll be able to provide something like that in future versions...> On the other had, Lc() compute the Lorenz > curve using these frequencies, but I don't manage to use its output to > compute the Gini coefficient. I wonder if you have already writen some > function to do this, or if you could shed some light here and help me.The naive approach would be to do yit_piit <- rep(yit, piit) i.e., to simply expand the full vector of income observations and then do Gini(yit_piit) etc. If the frequencies are not too large (and they only have to be specified up to a factor), this is a workaround which is not nice, but works reasonably well. Z> Thank you very much, > > Dimitri Szerman > > [[alternative HTML version deleted]] > > > > > > > _______________________________________________________ > > Instale o discador agora! http://br.acesso.yahoo.com/ > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html >