Skip to contents

Compute the Lorenz curve for microdata.

Usage

md_compute_lorenz(
  welfare,
  weight = rep(1, length(welfare)),
  nbins = if (length(welfare) > 1000) 100 else 20,
  force_nbins = TRUE
)

Arguments

welfare

numeric: A vector of income or consumption values.

weight

numeric: A vector of weights. Default is a vector of ones, rep(1, length(welfare)).

nbins

numeric: number of points on the Lorenz curve. if NULL the returning Lorenz curve would be the length of the original welfare vector minus the number of NAs of different observations in welfare and weight. Default is 100 for length(welfare) > 1000 and 20 otherwise.

force_nbins

logical; Force the creation of exact nbins even there is no actual data that falls in the corresponding interval. This implies that some observations will be repeated.

Value

data.frame

Details

Given a vector of weights and welfare, this functions computes the Lorenz curve.

Examples

md_compute_lorenz(welfare = md_ABC_2010_income$welfare,
weight = md_ABC_2010_income$weight)
#>         welfare lorenz_welfare lorenz_weight
#> 1      527466.5   0.0003376957    0.01012139
#> 2      770944.8   0.0012620532    0.02032103
#> 3      956874.9   0.0024979306    0.03066850
#> 4     1050884.1   0.0039694182    0.04114639
#> 5     1088278.0   0.0055054984    0.05138952
#> 6     1213282.9   0.0069577274    0.06045007
#> 7     1286504.4   0.0086596025    0.07031060
#> 8     1412181.0   0.0105074124    0.08029286
#> 9     1476508.8   0.0125630830    0.09055337
#> 10    1560126.0   0.0146654700    0.10050955
#> 11    1647038.0   0.0170353490    0.11100483
#> 12    1737304.5   0.0193014485    0.12063059
#> 13    1848083.6   0.0219092632    0.13109979
#> 14    1903261.5   0.0242845665    0.14015165
#> 15    1971652.5   0.0271715228    0.15078606
#> 16    2047943.5   0.0298738151    0.16044659
#> 17    2143238.5   0.0335044068    0.17281138
#> 18    2221881.2   0.0360345836    0.18112413
#> 19    2271607.0   0.0390183463    0.19068902
#> 20    2378096.0   0.0425773133    0.20167994
#> 21    2423298.2   0.0463684614    0.21295781
#> 22    2468756.8   0.0490135520    0.22072276
#> 23    2528214.5   0.0522747303    0.23003548
#> 24    2590368.5   0.0562543999    0.24118292
#> 25    2691228.8   0.0595428468    0.25009565
#> 26    2807437.5   0.0634174534    0.26028660
#> 27    2843264.0   0.0672974389    0.27014713
#> 28    2899196.2   0.0713083959    0.28020764
#> 29    2941314.5   0.0754888626    0.29049424
#> 30    2983189.0   0.0794214244    0.30002435
#> 31    3039593.5   0.0836239417    0.31005878
#> 32    3092553.8   0.0883756119    0.32118013
#> 33    3156643.5   0.0925633553    0.33076241
#> 34    3249655.0   0.0973062044    0.34133595
#> 35    3284760.0   0.1013468147    0.35022260
#> 36    3370602.8   0.1058835431    0.36003965
#> 37    3483609.0   0.1110439114    0.37090014
#> 38    3574020.5   0.1165914849    0.38221279
#> 39    3630684.8   0.1205340003    0.39007339
#> 40    3701176.5   0.1258161459    0.40041216
#> 41    3797451.8   0.1308362005    0.41003791
#> 42    3851052.5   0.1362041929    0.42010713
#> 43    3988344.0   0.1417637218    0.43025460
#> 44    4126599.0   0.1479052345    0.44113248
#> 45    4175654.2   0.1531242354    0.45016695
#> 46    4278784.0   0.1598269479    0.46154047
#> 47    4330308.0   0.1649856396    0.47014886
#> 48    4450651.0   0.1710469151    0.48003548
#> 49    4583402.5   0.1786654814    0.49207854
#> 50    4676065.0   0.1840867873    0.50046955
#> 51    4799488.5   0.1906791219    0.51041703
#> 52    4921696.0   0.1975220263    0.52052103
#> 53    5056518.0   0.2043279407    0.53032938
#> 54    5222615.0   0.2116179827    0.54047685
#> 55    5289737.0   0.2194971847    0.55123300
#> 56    5325424.0   0.2261619839    0.56024138
#> 57    5465240.5   0.2339040035    0.57058015
#> 58    5664699.0   0.2417327990    0.58066676
#> 59    5734393.5   0.2494474363    0.59037947
#> 60    5786693.5   0.2573803035    0.60027477
#> 61    5921869.5   0.2656260514    0.61037007
#> 62    6020719.0   0.2736847308    0.62005669
#> 63    6078579.0   0.2833664089    0.63154325
#> 64    6165239.0   0.2909918505    0.64049946
#> 65    6313356.0   0.3014843679    0.65260339
#> 66    6400624.0   0.3082930402    0.66029877
#> 67    6598847.0   0.3183028915    0.67135926
#> 68    6723124.0   0.3278916467    0.68168064
#> 69    6917179.5   0.3358297870    0.69000209
#> 70    7015360.0   0.3459946283    0.70049737
#> 71    7169986.0   0.3559772027    0.71060137
#> 72    7399422.0   0.3680075043    0.72242705
#> 73    7537658.0   0.3760000452    0.73013113
#> 74    7890955.0   0.3879857456    0.74129595
#> 75    8235175.5   0.3989193499    0.75094779
#> 76    8477008.0   0.4121598970    0.76234740
#> 77    8677887.0   0.4223627064    0.77089493
#> 78    8974374.0   0.4341605146    0.78047720
#> 79    9307018.0   0.4470115532    0.79058989
#> 80    9510035.0   0.4598769242    0.80035477
#> 81    9731732.0   0.4733182799    0.81036312
#> 82   10219490.0   0.4874193707    0.82044972
#> 83   10415763.0   0.5098227161    0.83596223
#> 84   10547598.0   0.5157629876    0.84003165
#> 85   10824170.0   0.5306387951    0.85004869
#> 86   11252204.0   0.5481878186    0.86148308
#> 87   11522499.0   0.5624545003    0.87049146
#> 88   12320558.0   0.5798950032    0.88096066
#> 89   13034536.0   0.5964953435    0.89037773
#> 90   14178849.0   0.6188846955    0.90215123
#> 91   15090150.0   0.6363639799    0.91068137
#> 92   16546611.0   0.6580029663    0.92045494
#> 93   18590828.0   0.6863040844    0.93184585
#> 94   19756928.0   0.7086763293    0.94013252
#> 95   22015660.0   0.7380363025    0.95017565
#> 96   24556662.0   0.7700535669    0.96026225
#> 97   26591538.0   0.8061904272    0.97024451
#> 98   34345624.0   0.8546482546    0.98131369
#> 99   50928228.0   0.9040598086    0.99000035
#> 100 236313152.0   1.0000000000    1.00000000