{ "cells": [ { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "# Exercise set 8: Heterogeneous treatment effectts\n", "\n", "In this exercise set we will be working with estimation of conditional average treatment effects assuming selection on observables. \n", "\n", "First we will use the `econml` package in Python to estimate a double machine learning causal forest, and in the second part we will use the `grf` package in R to estimate a causal forest.\n", "\n", "In this exercise we will be using data from LaLonde, R. J. (1986). Evaluating the econometric evaluations of training programs with experimental data. The American economic review, 604-620, regarding a job training field experiment, where we will examine possible treatment effect heterogeneity treatment effects, downloaded from [NYU](https://users.nber.org/~rdehejia/nswdata.html) but supplied to you in `csv` format in a sligthly cleaned format. The object of interest is real earnings in 1978 and we assume selection on observables and overlap.\n", "\n", "## Python\n", "\n", "In this first part of the exercise, we will be utilizing Python and `econml`.\n", "\n", "First we load some packages and the data." ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " | treat | \n", "age | \n", "education | \n", "black | \n", "hispanic | \n", "married | \n", "nodegree | \n", "re75 | \n", "re78 | \n", "
---|---|---|---|---|---|---|---|---|---|
count | \n", "705.000000 | \n", "705.000000 | \n", "705.000000 | \n", "705.000000 | \n", "705.000000 | \n", "705.000000 | \n", "705.000000 | \n", "705.000000 | \n", "705.000000 | \n", "
mean | \n", "0.415603 | \n", "24.607092 | \n", "10.272340 | \n", "0.795745 | \n", "0.107801 | \n", "0.164539 | \n", "0.774468 | \n", "3116.271386 | \n", "5586.166074 | \n", "
std | \n", "0.493176 | \n", "6.666376 | \n", "1.720412 | \n", "0.403443 | \n", "0.310350 | \n", "0.371027 | \n", "0.418229 | \n", "5104.566478 | \n", "6269.582709 | \n", "
min | \n", "0.000000 | \n", "17.000000 | \n", "3.000000 | \n", "0.000000 | \n", "0.000000 | \n", "0.000000 | \n", "0.000000 | \n", "0.000000 | \n", "0.000000 | \n", "
25% | \n", "0.000000 | \n", "19.000000 | \n", "9.000000 | \n", "1.000000 | \n", "0.000000 | \n", "0.000000 | \n", "1.000000 | \n", "0.000000 | \n", "0.000000 | \n", "
50% | \n", "0.000000 | \n", "23.000000 | \n", "10.000000 | \n", "1.000000 | \n", "0.000000 | \n", "0.000000 | \n", "1.000000 | \n", "1122.621000 | \n", "4159.919000 | \n", "
75% | \n", "1.000000 | \n", "27.000000 | \n", "11.000000 | \n", "1.000000 | \n", "0.000000 | \n", "0.000000 | \n", "1.000000 | \n", "4118.681000 | \n", "8881.665000 | \n", "
max | \n", "1.000000 | \n", "55.000000 | \n", "16.000000 | \n", "1.000000 | \n", "1.000000 | \n", "1.000000 | \n", "1.000000 | \n", "37431.660000 | \n", "60307.930000 | \n", "