R/ff_dist_gini.R
ff_dist_gini_vector_pos.Rd
See vignette for details, but very simple one line algorithm that computes gini for a pos or zero data vector. This does not work with negative values. Additionally, this is not for a sample, the vector is the population. Also note while the highest equality is 0, the greatest inequality only asymptotes to 1, but equals to (n-1)/(n+1).
ff_dist_gini_vector_pos(ar_pos)
array of numeric values that are all non-negative
a scalar value of the gini coefficient
https://fanwangecon.github.io/REconTools/reference/ff_dist_gini_vector_pos.html https://fanwangecon.github.io/REconTools/articles/fv_dist_gini_vector_pos.html https://github.com/FanWangEcon/REconTools/blob/master/R/ff_dist_gini.R
ar_equal_n2 = c(1,1)
ar_ineql_alittle_n2 = c(1,2)
ar_ineql_somewht_n2 = c(1,2^3)
ar_ineql_alotine_n2 = c(1,2^5)
ar_ineql_veryvry_n2 = c(1,2^8)
ar_ineql_mostmst_n2 = c(1,2^13)
# Beta draw testing
ar_beta_mostrich_n1000 = rbeta(1000, 5, 1)
ar_beta_mostpoor_n1000 = rbeta(1000, 1, 5)
ar_beta_manyrichmanypoor_nomiddle_n1000 = rbeta(1000, 0.5, 0.5)
ff_dist_gini_vector_pos(ar_equal_n2)
#> Warning: Data vector has only n=2, max-inequality/min-gini=0.333333333333333
#> [1] 0
ff_dist_gini_vector_pos(ar_ineql_alittle_n2)
#> Warning: Data vector has only n=2, max-inequality/min-gini=0.333333333333333
#> [1] 0.1111111
ff_dist_gini_vector_pos(ar_ineql_somewht_n2)
#> Warning: Data vector has only n=2, max-inequality/min-gini=0.333333333333333
#> [1] 0.2592593
ff_dist_gini_vector_pos(ar_ineql_alotine_n2)
#> Warning: Data vector has only n=2, max-inequality/min-gini=0.333333333333333
#> [1] 0.3131313
ff_dist_gini_vector_pos(ar_ineql_mostmst_n2)
#> Warning: Data vector has only n=2, max-inequality/min-gini=0.333333333333333
#> [1] 0.333252
ff_dist_gini_vector_pos(ar_beta_mostrich_n1000)
#> [1] 0.09144686
ff_dist_gini_vector_pos(ar_beta_mostpoor_n1000)
#> [1] 0.4499927
ff_dist_gini_vector_pos(ar_beta_manyrichmanypoor_nomiddle_n1000)
#> [1] 0.3977155