{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# A Simple Example on Creating a Custom Refutation Using User-Defined Outcome Functions\n", "In this experiment, we define a linear dataset. In order to find the coefficients, we make use of the linear regression estimator. In order to test the effectiveness of the linear estimator, we now replace the outcome value with a dummy produced with the help of a linear expression based on the value of the confounders. This effectively means that the effect of the treatment on the outcome should be zero. This is exactly, what we should expect from the results of the refuter." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Insert Dependencies" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "from dowhy import CausalModel\n", "import dowhy.datasets\n", "import pandas as pd\n", "import numpy as np\n", "\n", "# Config dict to set the logging level\n", "import logging.config\n", "DEFAULT_LOGGING = {\n", " 'version': 1,\n", " 'disable_existing_loggers': False,\n", " 'loggers': {\n", " '': {\n", " 'level': 'WARN',\n", " },\n", " }\n", "}\n", "\n", "logging.config.dictConfig(DEFAULT_LOGGING)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Create the Dataset\n", "You can change the values of the hyper params to see how the effects change, as each parameter changes\n", "Variable Guide:\n", "\n", "| Variable Name | Data Type | Interpretation |\n", "|-----------------|-----------|--------------------|\n", "| $Z_i$ | float | Insrument Variable |\n", "| $W_i$ | float | Confounder |\n", "| $v_0$ | float | Treatment |\n", "| $y$ | float | Outcome |\n", "\n" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " | Z0 | \n", "W0 | \n", "W1 | \n", "v0 | \n", "y | \n", "
---|---|---|---|---|---|
0 | \n", "1.0 | \n", "0.112689 | \n", "-0.501474 | \n", "8.076574 | \n", "80.106461 | \n", "
1 | \n", "0.0 | \n", "0.645347 | \n", "-0.072829 | \n", "-0.219279 | \n", "-0.092377 | \n", "
2 | \n", "0.0 | \n", "0.323480 | \n", "0.989825 | \n", "0.365947 | \n", "6.900517 | \n", "
3 | \n", "0.0 | \n", "0.030437 | \n", "1.334423 | \n", "1.740524 | \n", "20.319910 | \n", "
4 | \n", "1.0 | \n", "1.377841 | \n", "0.628397 | \n", "11.938058 | \n", "125.523936 | \n", "