R/gini.w.R

Defines functions gini.w

Documented in gini.w

gini.w <-
function(x, weight){
  n <- length(x)
  ifelse(is.null(weight), weight <- rep(1, n), weight <- weight)
    gg <- sum(weight*sapply(1:n, function(i){
      sum(weight*abs(x[i] - x))}))
    GG <- gg/(2*(sum(weight)*sum(x*weight)))
  return(GG)
}

Try the affluenceIndex package in your browser

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

affluenceIndex documentation built on Jan. 5, 2022, 5:07 p.m.