{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-09-23T18:49:55.860428Z",
     "start_time": "2019-09-23T18:49:53.074792Z"
    }
   },
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import numpy as np\n",
    "import scipy as sp\n",
    "import seaborn as sns\n",
    "import pathlib\n",
    "%matplotlib inline\n",
    "import matplotlib.pyplot as plt\n",
    "from plotnine import *"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-09-23T18:49:55.867404Z",
     "start_time": "2019-09-23T18:49:55.861419Z"
    }
   },
   "outputs": [],
   "source": [
    "def make_data_imbens(df):\n",
    "    df_new = df.drop(['nodegree'], axis=1)\n",
    "    df_new['pos74'] = (df_new['RE74'] > 0).astype(int)\n",
    "    df_new['pos75'] = (df_new['RE75'] > 0).astype(int)\n",
    "    return df_new"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-09-23T18:49:55.881366Z",
     "start_time": "2019-09-23T18:49:55.871393Z"
    }
   },
   "outputs": [],
   "source": [
    "col_names=['treatment', 'age', 'education', 'black', 'hispanic', 'married', 'nodegree', 'RE74', 'RE75', 'RE78']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-09-23T18:49:55.935228Z",
     "start_time": "2019-09-23T18:49:55.884359Z"
    }
   },
   "outputs": [],
   "source": [
    "control=pd.read_csv(pathlib.Path.cwd().parents[0].joinpath('data', 'nswre74_control.txt'), header=None, sep=r\"\\s\\s\", names=col_names, engine='python')\n",
    "treatment=pd.read_csv(pathlib.Path.cwd().parents[0].joinpath('data', 'nswre74_treated.txt'), header=None, sep=r\"\\s\\s\", names=col_names, engine='python')\n",
    "psid=pd.read_csv(pathlib.Path.cwd().parents[0].joinpath('data', 'psid_controls.txt'), header=None, sep=r\"\\s\\s\", names=col_names, engine='python')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-09-23T18:49:55.945196Z",
     "start_time": "2019-09-23T18:49:55.936219Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(260, 10) (185, 10) (2490, 10)\n"
     ]
    }
   ],
   "source": [
    "print(control.shape, treatment.shape, psid.shape)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-09-23T18:49:55.972124Z",
     "start_time": "2019-09-23T18:49:55.947191Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>treatment</th>\n",
       "      <th>age</th>\n",
       "      <th>education</th>\n",
       "      <th>black</th>\n",
       "      <th>hispanic</th>\n",
       "      <th>married</th>\n",
       "      <th>nodegree</th>\n",
       "      <th>RE74</th>\n",
       "      <th>RE75</th>\n",
       "      <th>RE78</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <td>0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>23.0</td>\n",
       "      <td>10.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>1</td>\n",
       "      <td>0.0</td>\n",
       "      <td>26.0</td>\n",
       "      <td>12.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>12383.68</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>2</td>\n",
       "      <td>0.0</td>\n",
       "      <td>22.0</td>\n",
       "      <td>9.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>3</td>\n",
       "      <td>0.0</td>\n",
       "      <td>18.0</td>\n",
       "      <td>9.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>10740.08</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>4</td>\n",
       "      <td>0.0</td>\n",
       "      <td>45.0</td>\n",
       "      <td>11.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>11796.47</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   treatment   age  education  black  hispanic  married  nodegree  RE74  RE75  \\\n",
       "0        0.0  23.0       10.0    1.0       0.0      0.0       1.0   0.0   0.0   \n",
       "1        0.0  26.0       12.0    0.0       0.0      0.0       0.0   0.0   0.0   \n",
       "2        0.0  22.0        9.0    1.0       0.0      0.0       1.0   0.0   0.0   \n",
       "3        0.0  18.0        9.0    1.0       0.0      0.0       1.0   0.0   0.0   \n",
       "4        0.0  45.0       11.0    1.0       0.0      0.0       1.0   0.0   0.0   \n",
       "\n",
       "       RE78  \n",
       "0      0.00  \n",
       "1  12383.68  \n",
       "2      0.00  \n",
       "3  10740.08  \n",
       "4  11796.47  "
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "imbens1 = pd.concat([control, treatment]).reset_index(drop=True)\n",
    "imbens1.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-09-23T18:49:55.996060Z",
     "start_time": "2019-09-23T18:49:55.975118Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>treatment</th>\n",
       "      <th>age</th>\n",
       "      <th>education</th>\n",
       "      <th>black</th>\n",
       "      <th>hispanic</th>\n",
       "      <th>married</th>\n",
       "      <th>RE74</th>\n",
       "      <th>RE75</th>\n",
       "      <th>RE78</th>\n",
       "      <th>pos74</th>\n",
       "      <th>pos75</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <td>0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>23.0</td>\n",
       "      <td>10.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>1</td>\n",
       "      <td>0.0</td>\n",
       "      <td>26.0</td>\n",
       "      <td>12.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>12383.68</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>2</td>\n",
       "      <td>0.0</td>\n",
       "      <td>22.0</td>\n",
       "      <td>9.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>3</td>\n",
       "      <td>0.0</td>\n",
       "      <td>18.0</td>\n",
       "      <td>9.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>10740.08</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>4</td>\n",
       "      <td>0.0</td>\n",
       "      <td>45.0</td>\n",
       "      <td>11.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>11796.47</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   treatment   age  education  black  hispanic  married  RE74  RE75      RE78  \\\n",
       "0        0.0  23.0       10.0    1.0       0.0      0.0   0.0   0.0      0.00   \n",
       "1        0.0  26.0       12.0    0.0       0.0      0.0   0.0   0.0  12383.68   \n",
       "2        0.0  22.0        9.0    1.0       0.0      0.0   0.0   0.0      0.00   \n",
       "3        0.0  18.0        9.0    1.0       0.0      0.0   0.0   0.0  10740.08   \n",
       "4        0.0  45.0       11.0    1.0       0.0      0.0   0.0   0.0  11796.47   \n",
       "\n",
       "   pos74  pos75  \n",
       "0      0      0  \n",
       "1      0      0  \n",
       "2      0      0  \n",
       "3      0      0  \n",
       "4      0      0  "
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "imbens1 = make_data_imbens(imbens1)\n",
    "imbens1.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-09-23T18:49:56.011020Z",
     "start_time": "2019-09-23T18:49:56.000050Z"
    }
   },
   "outputs": [],
   "source": [
    "imbens2 = pd.concat([treatment, psid]).reset_index(drop=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-09-23T18:49:56.047922Z",
     "start_time": "2019-09-23T18:49:56.015009Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>treatment</th>\n",
       "      <th>age</th>\n",
       "      <th>education</th>\n",
       "      <th>black</th>\n",
       "      <th>hispanic</th>\n",
       "      <th>married</th>\n",
       "      <th>RE74</th>\n",
       "      <th>RE75</th>\n",
       "      <th>RE78</th>\n",
       "      <th>pos74</th>\n",
       "      <th>pos75</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <td>0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>37.0</td>\n",
       "      <td>11.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>9930.0460</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>1</td>\n",
       "      <td>1.0</td>\n",
       "      <td>22.0</td>\n",
       "      <td>9.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>3595.8940</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>2</td>\n",
       "      <td>1.0</td>\n",
       "      <td>30.0</td>\n",
       "      <td>12.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>24909.4500</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>3</td>\n",
       "      <td>1.0</td>\n",
       "      <td>27.0</td>\n",
       "      <td>11.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>7506.1460</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>4</td>\n",
       "      <td>1.0</td>\n",
       "      <td>33.0</td>\n",
       "      <td>8.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>289.7899</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   treatment   age  education  black  hispanic  married  RE74  RE75  \\\n",
       "0        1.0  37.0       11.0    1.0       0.0      1.0   0.0   0.0   \n",
       "1        1.0  22.0        9.0    0.0       1.0      0.0   0.0   0.0   \n",
       "2        1.0  30.0       12.0    1.0       0.0      0.0   0.0   0.0   \n",
       "3        1.0  27.0       11.0    1.0       0.0      0.0   0.0   0.0   \n",
       "4        1.0  33.0        8.0    1.0       0.0      0.0   0.0   0.0   \n",
       "\n",
       "         RE78  pos74  pos75  \n",
       "0   9930.0460      0      0  \n",
       "1   3595.8940      0      0  \n",
       "2  24909.4500      0      0  \n",
       "3   7506.1460      0      0  \n",
       "4    289.7899      0      0  "
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "imbens2 = make_data_imbens(imbens2)\n",
    "imbens2.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-09-23T18:49:56.085820Z",
     "start_time": "2019-09-23T18:49:56.050914Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>treatment</th>\n",
       "      <th>age</th>\n",
       "      <th>education</th>\n",
       "      <th>black</th>\n",
       "      <th>hispanic</th>\n",
       "      <th>married</th>\n",
       "      <th>RE74</th>\n",
       "      <th>RE75</th>\n",
       "      <th>change_earnings</th>\n",
       "      <th>pos74</th>\n",
       "      <th>pos75</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <td>0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>37.0</td>\n",
       "      <td>11.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>9930.0460</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>1</td>\n",
       "      <td>1.0</td>\n",
       "      <td>22.0</td>\n",
       "      <td>9.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>3595.8940</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>2</td>\n",
       "      <td>1.0</td>\n",
       "      <td>30.0</td>\n",
       "      <td>12.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>24909.4500</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>3</td>\n",
       "      <td>1.0</td>\n",
       "      <td>27.0</td>\n",
       "      <td>11.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>7506.1460</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>4</td>\n",
       "      <td>1.0</td>\n",
       "      <td>33.0</td>\n",
       "      <td>8.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>289.7899</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   treatment   age  education  black  hispanic  married  RE74  RE75  \\\n",
       "0        1.0  37.0       11.0    1.0       0.0      1.0   0.0   0.0   \n",
       "1        1.0  22.0        9.0    0.0       1.0      0.0   0.0   0.0   \n",
       "2        1.0  30.0       12.0    1.0       0.0      0.0   0.0   0.0   \n",
       "3        1.0  27.0       11.0    1.0       0.0      0.0   0.0   0.0   \n",
       "4        1.0  33.0        8.0    1.0       0.0      0.0   0.0   0.0   \n",
       "\n",
       "   change_earnings  pos74  pos75  \n",
       "0        9930.0460      0      0  \n",
       "1        3595.8940      0      0  \n",
       "2       24909.4500      0      0  \n",
       "3        7506.1460      0      0  \n",
       "4         289.7899      0      0  "
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "imbens3 = pd.concat([treatment, psid]).reset_index(drop=True)\n",
    "imbens3['change_earnings'] = imbens3['RE78'] - imbens3['RE74']\n",
    "imbens3 = make_data_imbens(imbens3)\n",
    "imbens3 = imbens3.drop('RE78', axis=1)\n",
    "imbens3.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-09-23T18:49:56.110753Z",
     "start_time": "2019-09-23T18:49:56.088813Z"
    },
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>age</th>\n",
       "      <th>education</th>\n",
       "      <th>black</th>\n",
       "      <th>hispanic</th>\n",
       "      <th>married</th>\n",
       "      <th>nodegree</th>\n",
       "      <th>RE74</th>\n",
       "      <th>RE75</th>\n",
       "      <th>RE78</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>treatment</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <td>0.0</td>\n",
       "      <td>242</td>\n",
       "      <td>242</td>\n",
       "      <td>242</td>\n",
       "      <td>242</td>\n",
       "      <td>242</td>\n",
       "      <td>242</td>\n",
       "      <td>242</td>\n",
       "      <td>242</td>\n",
       "      <td>242</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>1.0</td>\n",
       "      <td>148</td>\n",
       "      <td>148</td>\n",
       "      <td>148</td>\n",
       "      <td>148</td>\n",
       "      <td>148</td>\n",
       "      <td>148</td>\n",
       "      <td>148</td>\n",
       "      <td>148</td>\n",
       "      <td>148</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "           age  education  black  hispanic  married  nodegree  RE74  RE75  \\\n",
       "treatment                                                                   \n",
       "0.0        242        242    242       242      242       242   242   242   \n",
       "1.0        148        148    148       148      148       148   148   148   \n",
       "\n",
       "           RE78  \n",
       "treatment        \n",
       "0.0         242  \n",
       "1.0         148  "
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "imbens4 = pd.concat([treatment, psid]).reset_index(drop=True)\n",
    "imbens4 = imbens4[~((imbens4['RE74'] >= 5000) | (imbens4['RE75'] >= 5000))]\n",
    "imbens4 = imbens4.reset_index(drop=True)\n",
    "#Does this match imbens' number of datapoints?\n",
    "imbens4.groupby('treatment').count()\n",
    "#yes!"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-09-23T18:49:56.137682Z",
     "start_time": "2019-09-23T18:49:56.112749Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>treatment</th>\n",
       "      <th>age</th>\n",
       "      <th>education</th>\n",
       "      <th>black</th>\n",
       "      <th>hispanic</th>\n",
       "      <th>married</th>\n",
       "      <th>RE74</th>\n",
       "      <th>RE75</th>\n",
       "      <th>RE78</th>\n",
       "      <th>pos74</th>\n",
       "      <th>pos75</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <td>0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>37.0</td>\n",
       "      <td>11.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>9930.0460</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>1</td>\n",
       "      <td>1.0</td>\n",
       "      <td>22.0</td>\n",
       "      <td>9.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>3595.8940</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>2</td>\n",
       "      <td>1.0</td>\n",
       "      <td>30.0</td>\n",
       "      <td>12.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>24909.4500</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>3</td>\n",
       "      <td>1.0</td>\n",
       "      <td>27.0</td>\n",
       "      <td>11.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>7506.1460</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>4</td>\n",
       "      <td>1.0</td>\n",
       "      <td>33.0</td>\n",
       "      <td>8.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>289.7899</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   treatment   age  education  black  hispanic  married  RE74  RE75  \\\n",
       "0        1.0  37.0       11.0    1.0       0.0      1.0   0.0   0.0   \n",
       "1        1.0  22.0        9.0    0.0       1.0      0.0   0.0   0.0   \n",
       "2        1.0  30.0       12.0    1.0       0.0      0.0   0.0   0.0   \n",
       "3        1.0  27.0       11.0    1.0       0.0      0.0   0.0   0.0   \n",
       "4        1.0  33.0        8.0    1.0       0.0      0.0   0.0   0.0   \n",
       "\n",
       "         RE78  pos74  pos75  \n",
       "0   9930.0460      0      0  \n",
       "1   3595.8940      0      0  \n",
       "2  24909.4500      0      0  \n",
       "3   7506.1460      0      0  \n",
       "4    289.7899      0      0  "
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "imbens4 = make_data_imbens(imbens4)\n",
    "imbens4.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-09-23T18:49:56.165607Z",
     "start_time": "2019-09-23T18:49:56.140673Z"
    }
   },
   "outputs": [],
   "source": [
    "def plot_treatment_graphs(df, name, outcome_col):\n",
    "    print(ggplot(df, aes(x = 'factor(treatment)', fill = 'factor(treatment)')) + geom_bar() + theme_light() + labs(title = name) + theme(figure_size = (3,3)))\n",
    "    print(ggplot(df, aes(x = 'factor(treatment)', y = 'age', fill = 'factor(treatment)')) + geom_boxplot() + labs(title = name) + theme_light() + theme(figure_size = (3,3)))\n",
    "    print(ggplot(df, aes(x = 'factor(treatment)', y = 'education', fill = 'factor(treatment)')) + geom_boxplot() + theme_light() + labs(title = name) + theme(figure_size = (3,3)))\n",
    "    print(ggplot(df, aes(x = 'factor(treatment)', y = 'RE74', fill = 'factor(treatment)')) + labs(title = name) + geom_boxplot() + theme_light() + theme(figure_size = (3,3)))\n",
    "    print(ggplot(df, aes(x = 'factor(treatment)', y = 'RE75', fill = 'factor(treatment)')) + labs(title = name) + geom_boxplot() + theme_light() + theme(figure_size = (3,3)))\n",
    "    print(ggplot(df, aes(x = 'factor(treatment)', y = outcome_col, fill = 'factor(treatment)')) + labs(title = name) + geom_boxplot() + scale_y_continuous() + theme_light() + theme(figure_size = (3,3)))\n",
    "    print(ggplot(df, aes(x = 'factor(treatment)', y = 'factor(black)', fill = 'factor(black)')) + geom_jitter() + labs(title = name) + theme_light() + theme(figure_size = (3,3)))\n",
    "    print(ggplot(df, aes(x = 'factor(treatment)', y = 'factor(hispanic)', fill = 'factor(hispanic)')) + geom_jitter() + labs(title = name) + theme_light() + theme(figure_size = (3,3)))\n",
    "    print(ggplot(df, aes(x = 'factor(treatment)', y = 'factor(married)', fill = 'factor(married)')) + geom_jitter() + labs(title = name) + theme_light() + theme(figure_size = (3,3)))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-09-23T18:50:00.900954Z",
     "start_time": "2019-09-23T18:49:56.168599Z"
    }
   },
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 16720 characters]\n",
      "text/plain": [
       "<Figure size 300x300 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<ggplot: (95414518753)>\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 19884 characters]\n",
      "text/plain": [
       "<Figure size 300x300 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<ggplot: (95414435718)>\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 19348 characters]\n",
      "text/plain": [
       "<Figure size 300x300 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<ggplot: (95414436907)>\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 26112 characters]\n",
      "text/plain": [
       "<Figure size 300x300 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<ggplot: (95415015281)>\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 26068 characters]\n",
      "text/plain": [
       "<Figure size 300x300 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<ggplot: (-9223371941438687463)>\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 21472 characters]\n",
      "text/plain": [
       "<Figure size 300x300 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<ggplot: (-9223371941438649326)>\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 79280 characters]\n",
      "text/plain": [
       "<Figure size 300x300 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<ggplot: (-9223371941438608296)>\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 78100 characters]\n",
      "text/plain": [
       "<Figure size 300x300 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<ggplot: (95416196521)>\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 80684 characters]\n",
      "text/plain": [
       "<Figure size 300x300 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<ggplot: (-9223371941438608149)>\n"
     ]
    }
   ],
   "source": [
    "plot_treatment_graphs(imbens1, 'imbens1', 'RE78')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-09-23T18:50:07.241001Z",
     "start_time": "2019-09-23T18:50:00.903947Z"
    }
   },
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 20600 characters]\n",
      "text/plain": [
       "<Figure size 300x300 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<ggplot: (-9223371941439760661)>\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 19296 characters]\n",
      "text/plain": [
       "<Figure size 300x300 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<ggplot: (-9223371941438506296)>\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 19904 characters]\n",
      "text/plain": [
       "<Figure size 300x300 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<ggplot: (-9223371941438686958)>\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 21264 characters]\n",
      "text/plain": [
       "<Figure size 300x300 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<ggplot: (95416337258)>\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 22368 characters]\n",
      "text/plain": [
       "<Figure size 300x300 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<ggplot: (-9223371941438555795)>\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 26036 characters]\n",
      "text/plain": [
       "<Figure size 300x300 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<ggplot: (95416154986)>\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 110060 characters]\n",
      "text/plain": [
       "<Figure size 300x300 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<ggplot: (95414949945)>\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 92500 characters]\n",
      "text/plain": [
       "<Figure size 300x300 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<ggplot: (95416259718)>\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 110356 characters]\n",
      "text/plain": [
       "<Figure size 300x300 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<ggplot: (-9223371941438626430)>\n"
     ]
    }
   ],
   "source": [
    "plot_treatment_graphs(imbens2, 'imbens2', 'RE78')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-09-23T18:50:11.757956Z",
     "start_time": "2019-09-23T18:50:07.242996Z"
    }
   },
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 20576 characters]\n",
      "text/plain": [
       "<Figure size 300x300 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<ggplot: (-9223371941438626381)>\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 19268 characters]\n",
      "text/plain": [
       "<Figure size 300x300 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<ggplot: (95415017599)>\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 19884 characters]\n",
      "text/plain": [
       "<Figure size 300x300 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<ggplot: (-9223371941438588598)>\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 21248 characters]\n",
      "text/plain": [
       "<Figure size 300x300 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<ggplot: (-9223371941439751224)>\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 22348 characters]\n",
      "text/plain": [
       "<Figure size 300x300 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<ggplot: (-9223371941439786706)>\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 26448 characters]\n",
      "text/plain": [
       "<Figure size 300x300 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<ggplot: (-9223371941438514067)>\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 110616 characters]\n",
      "text/plain": [
       "<Figure size 300x300 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<ggplot: (-9223371941438351174)>\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 93160 characters]\n",
      "text/plain": [
       "<Figure size 300x300 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<ggplot: (-9223371941438321618)>\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 111376 characters]\n",
      "text/plain": [
       "<Figure size 300x300 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<ggplot: (-9223371941438588584)>\n"
     ]
    }
   ],
   "source": [
    "plot_treatment_graphs(imbens3, 'imbens3', 'change_earnings')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-09-23T18:50:15.145864Z",
     "start_time": "2019-09-23T18:50:11.760915Z"
    }
   },
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 19252 characters]\n",
      "text/plain": [
       "<Figure size 300x300 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<ggplot: (-9223371941438588465)>\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 19288 characters]\n",
      "text/plain": [
       "<Figure size 300x300 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<ggplot: (-9223371941438649961)>\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 19232 characters]\n",
      "text/plain": [
       "<Figure size 300x300 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<ggplot: (95414503432)>\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 25308 characters]\n",
      "text/plain": [
       "<Figure size 300x300 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<ggplot: (95416424000)>\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 28044 characters]\n",
      "text/plain": [
       "<Figure size 300x300 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<ggplot: (95416192127)>\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 22540 characters]\n",
      "text/plain": [
       "<Figure size 300x300 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<ggplot: (-9223371941438356655)>\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 78148 characters]\n",
      "text/plain": [
       "<Figure size 300x300 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<ggplot: (95414950036)>\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 68928 characters]\n",
      "text/plain": [
       "<Figure size 300x300 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<ggplot: (95416126433)>\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 77716 characters]\n",
      "text/plain": [
       "<Figure size 300x300 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<ggplot: (-9223371941440345919)>\n"
     ]
    }
   ],
   "source": [
    "plot_treatment_graphs(imbens4, 'imbens4', 'RE78')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-09-23T18:52:51.260647Z",
     "start_time": "2019-09-23T18:52:51.248676Z"
    }
   },
   "outputs": [],
   "source": [
    "def plot_outcome_graphs(df, name, outcome_col):\n",
    "    print(ggplot(df, aes(x='factor(black)', y=outcome_col, fill='factor(black)'))+geom_boxplot()+labs(title=name)+facet_wrap('~treatment')+theme_light()+theme(figure_size=(3,3)))\n",
    "    print(ggplot(df, aes(x='factor(hispanic)', y=outcome_col, fill='factor(hispanic)'))+geom_boxplot()+labs(title=name)+facet_wrap('~treatment')+theme_light()+theme(figure_size=(3,3)))\n",
    "    print(ggplot(df, aes(x='factor(married)', y=outcome_col, fill='factor(married)'))+geom_boxplot()+labs(title=name)+facet_wrap('~treatment')+theme_light()+theme(figure_size=(3,3)))\n",
    "    print(ggplot(df, aes(x='age', y=outcome_col, fill='factor(treatment)'))+labs(title=name)+geom_point()+theme_light()+theme(figure_size=(3,3)))\n",
    "    print(ggplot(df, aes(x='RE74', y=outcome_col, fill='factor(treatment)'))+labs(title=name)+geom_point()+theme_light()+theme(figure_size=(3,3)))\n",
    "    print(ggplot(df, aes(x='RE75', y=outcome_col, fill='factor(treatment)'))+labs(title=name)+geom_point()+theme_light()+theme(figure_size=(3,3)))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-09-23T18:52:57.602908Z",
     "start_time": "2019-09-23T18:52:53.742233Z"
    }
   },
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 22504 characters]\n",
      "text/plain": [
       "<Figure size 300x300 with 2 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<ggplot: (-9223371941438311108)>\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 23352 characters]\n",
      "text/plain": [
       "<Figure size 300x300 with 2 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<ggplot: (95417569905)>\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 22928 characters]\n",
      "text/plain": [
       "<Figure size 300x300 with 2 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<ggplot: (95416384043)>\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 53028 characters]\n",
      "text/plain": [
       "<Figure size 300x300 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<ggplot: (-9223371941437210389)>\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 38572 characters]\n",
      "text/plain": [
       "<Figure size 300x300 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<ggplot: (-9223371941438610158)>\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 40132 characters]\n",
      "text/plain": [
       "<Figure size 300x300 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<ggplot: (95416229752)>\n"
     ]
    }
   ],
   "source": [
    "plot_outcome_graphs(imbens1, 'imbens1', 'RE78')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-09-23T18:53:03.535049Z",
     "start_time": "2019-09-23T18:52:57.605902Z"
    }
   },
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 27544 characters]\n",
      "text/plain": [
       "<Figure size 300x300 with 2 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<ggplot: (-9223371941438630512)>\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 28496 characters]\n",
      "text/plain": [
       "<Figure size 300x300 with 2 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<ggplot: (95416201364)>\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 28176 characters]\n",
      "text/plain": [
       "<Figure size 300x300 with 2 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<ggplot: (95416447401)>\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 107508 characters]\n",
      "text/plain": [
       "<Figure size 300x300 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<ggplot: (95416092108)>\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 66048 characters]\n",
      "text/plain": [
       "<Figure size 300x300 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<ggplot: (95414981075)>\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 63668 characters]\n",
      "text/plain": [
       "<Figure size 300x300 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<ggplot: (-9223371941438583559)>\n"
     ]
    }
   ],
   "source": [
    "plot_outcome_graphs(imbens2, 'imbens2', 'RE78')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-09-23T18:53:09.576891Z",
     "start_time": "2019-09-23T18:53:03.539035Z"
    }
   },
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 28808 characters]\n",
      "text/plain": [
       "<Figure size 300x300 with 2 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<ggplot: (-9223371941439797262)>\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 29884 characters]\n",
      "text/plain": [
       "<Figure size 300x300 with 2 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<ggplot: (95416231025)>\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 28860 characters]\n",
      "text/plain": [
       "<Figure size 300x300 with 2 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<ggplot: (95417709695)>\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 79884 characters]\n",
      "text/plain": [
       "<Figure size 300x300 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<ggplot: (-9223371941437008573)>\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 55784 characters]\n",
      "text/plain": [
       "<Figure size 300x300 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<ggplot: (-9223371941436991151)>\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 58268 characters]\n",
      "text/plain": [
       "<Figure size 300x300 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<ggplot: (95417767190)>\n"
     ]
    }
   ],
   "source": [
    "plot_outcome_graphs(imbens3, 'imbens3', 'change_earnings')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-09-23T18:53:14.291283Z",
     "start_time": "2019-09-23T18:53:09.579882Z"
    }
   },
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 24320 characters]\n",
      "text/plain": [
       "<Figure size 300x300 with 2 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<ggplot: (-9223371941436990215)>\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 24572 characters]\n",
      "text/plain": [
       "<Figure size 300x300 with 2 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<ggplot: (-9223371941436789900)>\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 24416 characters]\n",
      "text/plain": [
       "<Figure size 300x300 with 2 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<ggplot: (-9223371941437064956)>\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 50708 characters]\n",
      "text/plain": [
       "<Figure size 300x300 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<ggplot: (-9223371941438630624)>\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 39212 characters]\n",
      "text/plain": [
       "<Figure size 300x300 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<ggplot: (-9223371941438317645)>\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 41448 characters]\n",
      "text/plain": [
       "<Figure size 300x300 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<ggplot: (95414981012)>\n"
     ]
    }
   ],
   "source": [
    "plot_outcome_graphs(imbens4, 'imbens4', 'RE78')"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  },
  "varInspector": {
   "cols": {
    "lenName": 16,
    "lenType": 16,
    "lenVar": 40
   },
   "kernels_config": {
    "python": {
     "delete_cmd_postfix": "",
     "delete_cmd_prefix": "del ",
     "library": "var_list.py",
     "varRefreshCmd": "print(var_dic_list())"
    },
    "r": {
     "delete_cmd_postfix": ") ",
     "delete_cmd_prefix": "rm(",
     "library": "var_list.r",
     "varRefreshCmd": "cat(var_dic_list()) "
    }
   },
   "types_to_exclude": [
    "module",
    "function",
    "builtin_function_or_method",
    "instance",
    "_Feature"
   ],
   "window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
