{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# 12 - Doubly Robust Estimation\n", "\n", "## Don't Put All your Eggs in One Basket\n", "\n", "We've learned how to use linear regression and propensity score weighting to estimate $E[Y|T=1] - E[Y|T=0] | X$. But which one should we use and when? When in doubt, just use both! Doubly Robust Estimation is a way of combining propensity score and linear regression in a way you don't have to rely on either of them. \n", "\n", "To see how this works, let's consider the mindset experiment. It is a randomised study conducted in U.S. public high schools which aims at finding the impact of a growth mindset. The way it works is that students receive from the school a seminar to instil in them a growth mindset. Then, they follow up with the students in their college years to measure how well they performed academically. This measurement was compiled into an achievement score and standardised. The real data on this study is not publicly available in order to preserve students' privacy. However, we have a simulated dataset with the same statistical properties provided by [Athey and Wager](https://arxiv.org/pdf/1902.07409.pdf), so we will use that instead." ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "ExecuteTime": { "end_time": "2023-03-14T11:05:50.498438Z", "start_time": "2023-03-14T11:05:46.659452Z" }, "tags": [ "hide-input" ] }, "outputs": [], "source": [ "import warnings\n", "warnings.filterwarnings('ignore')\n", "\n", "import pandas as pd\n", "import numpy as np\n", "from matplotlib import style\n", "from matplotlib import pyplot as plt\n", "import seaborn as sns\n", "\n", "from sklearn.linear_model import LogisticRegression, LinearRegression\n", "\n", "%matplotlib inline\n", "\n", "style.use(\"fivethirtyeight\")\n", "pd.set_option(\"display.max_columns\", 6)" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "ExecuteTime": { "end_time": "2023-03-14T11:05:50.535134Z", "start_time": "2023-03-14T11:05:50.500165Z" } }, "outputs": [ { "data": { "text/html": [ "
\n", " | schoolid | \n", "intervention | \n", "achievement_score | \n", "... | \n", "school_ethnic_minority | \n", "school_poverty | \n", "school_size | \n", "
---|---|---|---|---|---|---|---|
259 | \n", "73 | \n", "1 | \n", "1.480828 | \n", "... | \n", "-0.515202 | \n", "-0.169849 | \n", "0.173954 | \n", "
3435 | \n", "76 | \n", "0 | \n", "-0.987277 | \n", "... | \n", "-1.310927 | \n", "0.224077 | \n", "-0.426757 | \n", "
9963 | \n", "4 | \n", "0 | \n", "-0.152340 | \n", "... | \n", "0.875012 | \n", "-0.724801 | \n", "0.761781 | \n", "
4488 | \n", "67 | \n", "0 | \n", "0.358336 | \n", "... | \n", "0.315755 | \n", "0.054586 | \n", "1.862187 | \n", "
2637 | \n", "16 | \n", "1 | \n", "1.360920 | \n", "... | \n", "-0.033161 | \n", "-0.982274 | \n", "1.591641 | \n", "
5 rows × 13 columns
\n", "