euromod.eu_euromod.calibrate.weighted¶
Weighted statistics on arrays: mean, percentile and Gini coefficient.
Every function takes plain arrays of values and survey weights (dwt in EUROMOD
output) and returns a number.
Below are listed the main public classes of the euromod.eu_euromod.calibrate.weighted module.
|
Weighted Gini coefficient, from the area under the Lorenz curve (trapezoids). |
|
Weighted mean. |
|
Weighted percentile: the smallest value whose cumulative weight reaches the |
Functions¶
- euromod.eu_euromod.calibrate.weighted.gini(values, weights)¶
Weighted Gini coefficient, from the area under the Lorenz curve (trapezoids).
- Parameters:
values (array-like) – Values (e.g. household income) and their weights, of equal length. Observations where either is missing are left out.
weights (array-like) – Values (e.g. household income) and their weights, of equal length. Observations where either is missing are left out.
- Returns:
0 when everyone has the same value, approaching 1 as it concentrates.
- Return type:
- euromod.eu_euromod.calibrate.weighted.weighted_mean(values, weights)¶
Weighted mean.
- Parameters:
values (array-like) – Values and their weights, of equal length.
weights (array-like) – Values and their weights, of equal length.
- Return type:
- euromod.eu_euromod.calibrate.weighted.weighted_percentile(values, weights, percentile)¶
Weighted percentile: the smallest value whose cumulative weight reaches the requested share of the total weight.
The result is always one of
values; nothing is interpolated.