PovertyAndInequalityMeasures
This generates various measures poverty and inequality from a sample dataset.
The measures are mostly taken from chs. 4-6 of the World Banks' Handbook on Poverty and Inequality.
See the test case for worked examples
Poverty:
These routines can use both 2d arrays and dataframes as inputs For the arrays, supply with integers giving the columns holding weights and incomes; for the frames, the names of the columns (as symbols).
function makepoverty(
rawdata :: Array{<:Real, 2},
line :: Real,
growth :: Real,
weightpos :: Integer = 1,
incomepos :: Integer = 2,
foster_greer_thorndyke_alphas :: AbstractArray{<:Real, 1} = DEFAULT_FGT_ALPHAS ) :: OutputDict
function makepoverty(
rawdata,
line :: Real,
growth :: Real,
weightcol :: Symbol,
incomecol :: Symbol,
foster_greer_thorndyke_alphas :: AbstractArray{<:Real, 1} = DEFAULT_FGT_ALPHAS,
) :: OutputDict
notes:
rawdata
- each row is an observation; one col should be a weight, another is income;
positions assumed to be 1 and 2 unless weight and incomepos are supplied (or names as symbols for the frame version)
- the dataframe version can use anything that supports the Queryverse iterable table interface;
line
- a poverty line. This is the same for for all observations, the income measure needs to be equivalised if the line differs by family size, etc.;foster_greer_thorndyke_alphas
- coefficients for Foster-Greer Thorndyke poverty measures (see World Bank, ch. 4); note that FGT(0)
corresponds to the headcount measure and FGT(1) to poverty gap; count and gap are computed directly anyway but it's worth checking one against the other;
growth
is (e.g.) 0.01 for 1% per period, and is used for 'time to exit' measure.
Output is dictionary with an entry for each measure.
Inequality
Usage is similar to makepoverty
above. See chs 5 and 6 of the World Bank book, and the test case for more detail.
Version1:
function makeinequality(
rawdata :: Array{<:Real, 2 },
weightpos :: Integer = 1,
incomepos :: Integer = 2,
atkinson_es :: AbstractArray{<:Real, 1} = DEFAULT_ATKINSON_ES,
generalised_entropy_alphas :: AbstractArray{<:Real, 1} = DEFAULT_ENTROPIES ) :: OutputDict
function makeinequality(
rawdata,
weightcol :: Symbol,
incomecol :: Symbol,
atkinson_es :: AbstractArray{<:Real, 1} = DEFAULT_ATKINSON_ES,
generalised_entropy_alphas :: AbstractArray{<:Real, 1} = DEFAULT_ENTROPIES ) :: OutputDict
Notes:
rawdata
a matrix with cols with weights and incomes;atkinson_es
inequality aversion values for the Atkinson indexes;generalised_entropy_alphas
vaues for Theil entropy measure;weightpos
- column with weightsincomepos
- column with incomes
Return is a also a Dict of inequality measures.
There's also a method:
function adddecomposedtheil( popindic :: OutputDict, subindices :: OutputDictArray ) :: OutputDict
which takes an array of output dicts, broken down by (e.g.) Regions, Genders, etc. and produces a Theil index decomposition from them.
There's also a small binify
routine which chops a dataset up into chunks of cumulative income and population suitable for drawing Lorenz Curves.
PovertyAndInequalityMeasures.add_decomposed_theil
PovertyAndInequalityMeasures.binify
PovertyAndInequalityMeasures.binify
PovertyAndInequalityMeasures.make_all_below_line
PovertyAndInequalityMeasures.make_augmented
PovertyAndInequalityMeasures.make_augmented
PovertyAndInequalityMeasures.make_gini
PovertyAndInequalityMeasures.make_inequality
PovertyAndInequalityMeasures.make_inequality
PovertyAndInequalityMeasures.make_inequalityinternal
PovertyAndInequalityMeasures.make_poverty
PovertyAndInequalityMeasures.make_poverty
PovertyAndInequalityMeasures.make_povertyinternal
PovertyAndInequalityMeasures.add_decomposed_theil
— MethodMake a wee dict with :theilbetween and :theilwithin See WB eqns 6.7/6.8. TODO
- there are some papers on decomposing Atkinson, but I
don't understand them ..
- the over time 3-part version
popindic : Inequal for the population as a whole subindices : an array of dics, one for each subgroup of interest
PovertyAndInequalityMeasures.binify
— FunctionChop a dataset with populations and incomes into numbins groups in a form suitable for e.g. a Gini curve.
- col1 is cumulative population,
- 2 cumulative income/whatever,
- 3 threshold income level.
PovertyAndInequalityMeasures.binify
— MethodAs above, but using any DataFrame like thing that supports the TableTraits.isiterabletable interface
PovertyAndInequalityMeasures.make_gini
— Methodcalculate a Gini coefficient on one of our sorted arrays
PovertyAndInequalityMeasures.make_inequality
— FunctionAs above but using the iterable table interface; see: https://github.com/queryverse/IterableTables.jl weightcol and incomecol are names of columns
PovertyAndInequalityMeasures.make_inequality
— FunctionMake a dictionary of inequality measures. This is mainly taken from chs 5 and 6 of the World Bank book.
rawdata
a matrix with cols with weights and incomesatkinson_es
inequality aversion values for the Atkinson indexesgeneralised_entropy_alphas
weightpos
- column with weightsincomepos
- column with incomes
PovertyAndInequalityMeasures.make_poverty
— FunctionAs above, but using the QueryVerse IterableTables interface rawdata - basically anything resembling a dataframe; see: [https://github.com/queryverse/IterableTables.jl] throws an exception if rawdata doesn't support iterabletable interface
PovertyAndInequalityMeasures.make_poverty
— FunctionCreate a dictionary of poverty measures.
This is based on the World Bank's Poverty Handbook by Haughton and Khandker.
Arguments:
rawdata
- an nxm array of real nunbers; each row is an observation; one col should be a weight, another is income; positions assumed to be 1 and 2 unless weight and incomepos are suppliedline
- a poverty line, assumed same for all obs (so income is assumed to be already equivalised)foster_greer_thorndyke_alphas
- coefficients for FGT poverty measures; note that FGT(0) corresponds to headcount and FGT(1) to gap; count and gap are computed directly anyway but it's worth checking one against the other.growth
is (e.g.) 0.01 for 1% per period, and is used for 'time to exit' measure.
PovertyAndInequalityMeasures.make_all_below_line
— Methodgenerate a subset of one of our datasets with just the elements whose incomes are below the line. Probably possible in 1 line, once I get the hang of this a bit more.
PovertyAndInequalityMeasures.make_augmented
— Functioninternal function that makes a sorted array with cumulative income and population added
PovertyAndInequalityMeasures.make_augmented
— Functioninternal function that makes a sorted array with cumulative income and population added
PovertyAndInequalityMeasures.make_inequalityinternal
— MethodMake a dictionary of inequality measures. This is mainly taken from chs 5 and 6 of the World Bank book.
rawdata
a matrix with cols with weights and incomesatkinson_es
inequality aversion values for the Atkinson indexesgeneralised_entropy_alphas
weightpos
- column with weightsincomepos
- column with incomes
PovertyAndInequalityMeasures.make_povertyinternal
— MethodInternal version, once we have our datatset
Bibliography
Cobham Alex, and Sumner Andy. “Is Inequality All about the Tails?: The Palma Measure of Income Inequality.” Significance 11, no. 1 (February 19, 2014): 10–13. https://doi.org/10.1111/j.1740-9713.2014.00718.x.
Haughton, Jonathan, and Shahidur R. Khandker. ‘Handbook on Poverty and Inequality’. The World Bank, 27 March 2009. http://documents.worldbank.org/curated/en/488081468157174849/Handbook-on-poverty-and-inequality.
Preston, Ian. ‘Inequality and Income Gaps’. IFS Working Paper. Institute for Fiscal Studies, 5 December 2006. https://econpapers.repec.org/paper/ifsifsewp/06_2f25.htm.
Reed, Howard, and Graham Stark. ‘Tackling Child Poverty Delivery Plan - Forecasting Child Poverty in Scotland’. Scottish Government, 9 March 2018. http://www.gov.scot/Publications/2018/03/2911/0.