{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Unemployment insurance vs. UBI\n", "\n", "Compare the poverty and distributional impacts of giving \\$600 per unemployment insurance beneficiary--as proposed in the latest CARES Act--to using the same amount for a UBI.\n", "\n", "Data: 2018 ASEC\n", "\n", "## Setup" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import pandas as pd\n", "import numpy as np\n", "import microdf as mdf\n", "import matplotlib.pyplot as plt\n", "import matplotlib as mpl\n", "import os" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Load data" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "ASEC_F = '~/data/asec/2019/pppub19.csv'\n", "\n", "SPM_COLS = ['povthreshold', 'resources', 'poor', 'numper', 'numkids',\n", " 'numadults', 'id', 'weight']\n", "OTHER_COLS = ['A_AGE', 'MARSUPWT', 'UC_VAL']\n", "cols = ['SPM_' + i.upper() for i in SPM_COLS] + OTHER_COLS\n", "\n", "raw = pd.read_csv(ASEC_F, usecols=cols)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Preprocess" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "df = raw.copy(deep=True)" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "df.columns = map(str.lower, df.columns)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Add true weight by dividing by 100." ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [], "source": [ "df['w'] = df.marsupwt / 100.\n", "df['spm_w'] = df.spm_weight / 100." ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "15.499327626209999" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "mdf.weighted_sum(df, 'uc_val', 'w') / 1e9" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Simulate" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [], "source": [ "UI_BONUS = 600 * 17" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [], "source": [ "df['ui_bonus'] = np.where(df.uc_val > 0, UI_BONUS, 0)" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " | ui_bonus | \n", "spm_resources | \n", "spm_povthreshold | \n", "spm_numper | \n", "spm_w | \n", "
---|---|---|---|---|---|
spm_id | \n", "\n", " | \n", " | \n", " | \n", " | \n", " |
4001 | \n", "0 | \n", "12961 | \n", "10080 | \n", "1 | \n", "2031.67 | \n", "
6001 | \n", "0 | \n", "13292 | \n", "11483 | \n", "1 | \n", "1232.04 | \n", "
7001 | \n", "0 | \n", "10232 | \n", "11483 | \n", "1 | \n", "1209.17 | \n", "
8001 | \n", "0 | \n", "20084 | \n", "16190 | \n", "2 | \n", "1146.23 | \n", "
13001 | \n", "0 | \n", "21534 | \n", "11546 | \n", "1 | \n", "1587.98 | \n", "
... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "
94629001 | \n", "0 | \n", "70975 | \n", "17526 | \n", "1 | \n", "444.01 | \n", "
94630001 | \n", "0 | \n", "28273 | \n", "20304 | \n", "2 | \n", "412.47 | \n", "
94631001 | \n", "0 | \n", "40796 | \n", "46249 | \n", "6 | \n", "515.55 | \n", "
94632001 | \n", "10200 | \n", "48348 | \n", "54069 | \n", "6 | \n", "391.67 | \n", "
94633001 | \n", "0 | \n", "35551 | \n", "24711 | \n", "2 | \n", "448.29 | \n", "
71517 rows × 5 columns
\n", "