R/gini.R

gini <-
function(x){
  x.sort<- sort(x)
  n<- length(x)
  ivect<- 1:length(x.sort)
  eins<- rep(1,length(x.sort))
  Gini<- 1/n*(n+1-2*(t(n+1-ivect)%*%x.sort)/(t(eins)%*%x.sort))
  Ginistar <- Gini * n/(n - 1)
  list(Gini=Gini,"bcGini"=Ginistar)
}

Try the acid package in your browser

Any scripts or data that you put into this service are public.

acid documentation built on May 1, 2019, 10:14 p.m.