{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Applying refutation tests to the Lalonde and IHDP datasets" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Import the Dependencies" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "import dowhy\n", "from dowhy import CausalModel\n", "import pandas as pd\n", "import numpy as np" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Loading the Dataset" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Infant Health and Development Program Dataset (IHDP)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The measurements used are on the child—birth weight, head circumference, weeks bornpreterm, birth order, first born, neonatal health index (see Scott and Bauer 1989), sex, twinstatus—as well as behaviors engaged in during the pregnancy—smoked cigarettes, drankalcohol, took drugs—and measurements on the mother at the time she gave birth—age,marital status, educational attainment (did not graduate from high school, graduated fromhigh school, attended some college but did not graduate, graduated from college), whethershe worked during pregnancy, whether she received prenatal care—and the site (8 total) inwhich the family resided at the start of the intervention. There are 6 continuous covariatesand 19 binary covariates.\n", "\n", "### Reference\n", "Hill, J. L. (2011). Bayesian nonparametric modeling for causal inference. Journal of Computational and Graphical Statistics, 20(1), 217-240. https://doi.org/10.1198/jcgs.2010.08162" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " | treatment | \n", "y_factual | \n", "y_cfactual | \n", "mu0 | \n", "mu1 | \n", "x1 | \n", "x2 | \n", "x3 | \n", "x4 | \n", "x5 | \n", "... | \n", "x16 | \n", "x17 | \n", "x18 | \n", "x19 | \n", "x20 | \n", "x21 | \n", "x22 | \n", "x23 | \n", "x24 | \n", "x25 | \n", "
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | \n", "True | \n", "5.599916 | \n", "4.318780 | \n", "3.268256 | \n", "6.854457 | \n", "-0.528603 | \n", "-0.343455 | \n", "1.128554 | \n", "0.161703 | \n", "-0.316603 | \n", "... | \n", "1 | \n", "1 | \n", "1 | \n", "1 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "
1 | \n", "False | \n", "6.875856 | \n", "7.856495 | \n", "6.636059 | \n", "7.562718 | \n", "-1.736945 | \n", "-1.802002 | \n", "0.383828 | \n", "2.244320 | \n", "-0.629189 | \n", "... | \n", "1 | \n", "1 | \n", "1 | \n", "1 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "
2 | \n", "False | \n", "2.996273 | \n", "6.633952 | \n", "1.570536 | \n", "6.121617 | \n", "-0.807451 | \n", "-0.202946 | \n", "-0.360898 | \n", "-0.879606 | \n", "0.808706 | \n", "... | \n", "1 | \n", "0 | \n", "1 | \n", "1 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "
3 | \n", "False | \n", "1.366206 | \n", "5.697239 | \n", "1.244738 | \n", "5.889125 | \n", "0.390083 | \n", "0.596582 | \n", "-1.850350 | \n", "-0.879606 | \n", "-0.004017 | \n", "... | \n", "1 | \n", "0 | \n", "1 | \n", "1 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "
4 | \n", "False | \n", "1.963538 | \n", "6.202582 | \n", "1.685048 | \n", "6.191994 | \n", "-1.045229 | \n", "-0.602710 | \n", "0.011465 | \n", "0.161703 | \n", "0.683672 | \n", "... | \n", "1 | \n", "1 | \n", "1 | \n", "1 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "
5 rows × 30 columns
\n", "\n", " | age | \n", "educ | \n", "black | \n", "hisp | \n", "married | \n", "nodegr | \n", "re74 | \n", "re75 | \n", "re78 | \n", "u74 | \n", "u75 | \n", "treat | \n", "
---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | \n", "37 | \n", "11 | \n", "1 | \n", "0 | \n", "1 | \n", "1 | \n", "0.0 | \n", "0.0 | \n", "9930.05 | \n", "1 | \n", "1 | \n", "True | \n", "
2 | \n", "22 | \n", "9 | \n", "0 | \n", "1 | \n", "0 | \n", "1 | \n", "0.0 | \n", "0.0 | \n", "3595.89 | \n", "1 | \n", "1 | \n", "True | \n", "
3 | \n", "30 | \n", "12 | \n", "1 | \n", "0 | \n", "0 | \n", "0 | \n", "0.0 | \n", "0.0 | \n", "24909.50 | \n", "1 | \n", "1 | \n", "True | \n", "
4 | \n", "27 | \n", "11 | \n", "1 | \n", "0 | \n", "0 | \n", "1 | \n", "0.0 | \n", "0.0 | \n", "7506.15 | \n", "1 | \n", "1 | \n", "True | \n", "
5 | \n", "33 | \n", "8 | \n", "1 | \n", "0 | \n", "0 | \n", "1 | \n", "0.0 | \n", "0.0 | \n", "289.79 | \n", "1 | \n", "1 | \n", "True | \n", "