{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "## Notes on Calculating Gini Coefficients...\n", "\n", "Gini coefficient \$ G \$:\n", "\n", "* Top \$ 1/5 \$ receives \$ 4/5 \$: \$ G = 3/5 \$\n", "* Top \$ 1/4 \$ receives \$ 3/4 \$: \$ G = 1/2 \$\n", "* Top \$ 1/3 \$ receives \$ 2/3 \$: \$ G = 1/3 \$\n", "\n", " \n", "\n", "**Wikipedia**: _Gini Coefficient_ : \"In economics, the Gini coefficient (/ˈdʒiːni/ JEE-nee), sometimes called Gini index, or Gini ratio, is a measure of statistical dispersion intended to represent the income or wealth distribution of a nation's residents, and is the most commonly used measurement of inequality. It was developed by the Italian statistician and sociologist Corrado Gini and published in his 1912 paper Variability and Mutability (Italian: Variabilità e mutabilità) ...\n", "\n", ">...The Gini coefficient measures the inequality among values of a frequency distribution (for example, levels of income). A Gini coefficient of zero expresses perfect equality, where all values are the same (for example, where everyone has the same income). A Gini coefficient of 1 (or 100%) expresses maximal inequality among values (e.g., for a large number of people, where only one person has all the income or consumption, and all others have none, the Gini coefficient will be very nearly one). However, a value greater than one may occur if some persons represent negative contribution to the total (for example, having negative income or wealth).... For OECD countries, in the late 20th century, considering the effect of taxes and transfer payments, the income Gini coefficient ranged between 0.24 and 0.49, with Slovenia being the lowest and Chile the highest....\n", "\n", ">An informative simplified case just distinguishes two levels of income, low and high. If the high income group is a proportion \$ u \$ of the population and earns a proportion \$ f \$ of all income, then the Gini coefficient is \$ f − u \$. An actual more graded distribution with these same values u and f will always have a higher Gini coefficient than \$ f − u \$...\n", "\n", "----\n", "\n", " class gini\n", " \n", " delong_classes.gini()\n", " delong_classes.gini.upper_class\n", " delong_classes.gini.share\n", " delong_classes.gini.income_ratio\n", "\n", " " ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "# class gini, for getting a sense of what a Gini coefficient\n", "# means, at least in the context of a two-class income \n", "# distribution...\n", "#\n", "# I find that the measure I want is some combination of (a) \n", "# how much richer the rich are as a multiple of the wealth\n", "# and income of the poor, divided by something that increases\n", "# as the proportion of the rich in the population goes up.\n", "# My intuition is that a society with a substantial upper-\n", "# middle class is in some sense less unequal than one with\n", "# a small upper class, even if the higher class's wealth and\n", "# income is the same multiple of the lower class's in both\n", "# cases.\n", "#\n", "# This may be wrong. But it is my intuition. And the Gini does\n", "# not really do this...\n", "#\n", "# This class will be kept in delong_classers...\n", "\n", "import numpy as np\n", "\n", "class gini:\n", " \"\"\"\n", " For a two-class distribution of income. Initialize \n", " the class with a size-of-upper-class variable\n", " equal to 1/5 and a share-of-upper-class variable\n", " equal to 4/5\n", " \"\"\"\n", " \n", " def __init__(self,\n", " upper_class = 1/5, # size of upper class\n", " share = 4/5 # share of upper class\n", " ):\n", " self.upper_class = upper_class\n", " self.share = share\n", " self.gini_value = self.share - self.upper_class\n", " self.income_ratio = ((self.share/self.upper_class)/\n", " ((1-self.share)/(1-self.upper_class)))\n" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", "SIZE OF UPPER CLASS, GINI, AND WEALTH RATIO\n", "\n", " Upper Gini Ratio\n", "0 0.01 0.98 9801.000000\n", "1 0.02 0.96 2401.000000\n", "2 0.03 0.94 1045.444444\n", "3 0.04 0.92 576.000000\n", "4 0.05 0.90 361.000000\n", "5 0.06 0.88 245.444444\n", "6 0.07 0.86 176.510204\n", "7 0.08 0.84 132.250000\n", "8 0.09 0.82 102.234568\n", "9 0.10 0.80 81.000000\n", "10 0.11 0.78 65.462810\n", "11 0.12 0.76 53.777778\n", "12 0.13 0.74 44.786982\n", "13 0.14 0.72 37.734694\n", "14 0.15 0.70 32.111111\n", "15 0.16 0.68 27.562500\n", "16 0.17 0.66 23.837370\n", "17 0.18 0.64 20.753086\n", "18 0.19 0.62 18.174515\n", "19 0.20 0.60 16.000000\n", "20 0.21 0.58 14.151927\n", "21 0.22 0.56 12.570248\n", "22 0.23 0.54 11.207940\n", "23 0.24 0.52 10.027778\n", "24 0.25 0.50 9.000000\n", "25 0.26 0.48 8.100592\n", "26 0.27 0.46 7.310014\n", "27 0.28 0.44 6.612245\n", "28 0.29 0.42 5.994055\n", "29 0.30 0.40 5.444444\n", "30 0.31 0.38 4.954214\n", "31 0.32 0.36 4.515625\n", "32 0.33 0.34 4.122130\n", "33 0.34 0.32 3.768166\n", "34 0.35 0.30 3.448980\n", "35 0.36 0.28 3.160494\n", "36 0.37 0.26 2.899196\n", "37 0.38 0.24 2.662050\n", "38 0.39 0.22 2.446417\n", "39 0.40 0.20 2.250000\n", "40 0.41 0.18 2.070791\n", "41 0.42 0.16 1.907029\n", "42 0.43 0.14 1.757166\n", "43 0.44 0.12 1.619835\n", "44 0.45 0.10 1.493827\n", "45 0.46 0.08 1.378072\n", "46 0.47 0.06 1.271616\n", "47 0.48 0.04 1.173611\n", "48 0.49 0.02 1.083299\n", "49 0.50 0.00 1.000000\n" ] } ], "source": [ "# print a table calculating the Gini coefficient and the\n", "# wealth of the upper class as a multiple of the wealth\n", "# of the lower class for an upper class of i% that receives\n", "# 1-i% of the income\n", "\n", "import pandas as pd\n", "\n", "Upper = []\n", "Gini = []\n", "Ratio = []\n", "\n", "for i in range(1,51):\n", " working = gini(upper_class=i/100, share=1-i/100)\n", " Upper = Upper + [i/100]\n", " Gini = Gini + [working.gini_value]\n", " Ratio = Ratio + [working.income_ratio]\n", " \n", "gini_df = pd.DataFrame()\n", "gini_df['Upper'] = Upper\n", "gini_df['Gini'] = Gini\n", "gini_df['Ratio'] = Ratio\n", "\n", "print(\"\")\n", "print(\"SIZE OF UPPER CLASS, GINI, AND WEALTH RATIO\")\n", "print(\"\")\n", "print(gini_df)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " \n", "\n", "----\n", "\n", "## Notes on Gini Coefficients \n", "\n", "\n", "\n", "### Catch Our Breath—Further Notes:\n", "\n", "
\n", "\n", "----\n", "\n", "* Weblog Support \n", "* nbViewer \n", "\n", " " ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.6.7" } }, "nbformat": 4, "nbformat_minor": 4 }