{
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "# Policy Evaluation and Self-Selection\n",
        "\n",
        "Module 7 notebook lab. This notebook uses an original Ceteris Lab synthetic teaching dataset and does not report real empirical findings.\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Learning goal\n",
        "Compare randomized and self-selected treatment comparisons.\n",
        "\n",
        "Dataset: MODULE7_PROGRAM_EVALUATION_SYNTHETIC. Variables: treatment, outcome, baseline_score, motivation_score.\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {},
      "outputs": [],
      "source": [
        "import pandas as pd\n",
        "import statsmodels.api as sm\n",
        "\n",
        "df = pd.read_csv(\"/data/module-7/module7_program_evaluation_synthetic.csv\")\n",
        "randomized = df[df[\"random_assignment\"] == 1]\n",
        "self_selected = df[df[\"self_selected\"] == 1]\n",
        "for name, sample in [(\"random assignment sample\", randomized), (\"self-selected participants\", self_selected)]:\n",
        "    model = sm.OLS(sample[\"outcome\"], sm.add_constant(sample[[\"treatment\", \"baseline_score\"]])).fit()\n",
        "    print(name, round(model.params[\"treatment\"], 3))\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Reflection\n",
        "Write two sentences: one coefficient, group difference, or predicted-probability interpretation, and one limitation or coding choice that matters.\n"
      ]
    }
  ],
  "metadata": {
    "kernelspec": {
      "display_name": "Python 3",
      "language": "python",
      "name": "python3"
    },
    "language_info": {
      "name": "python",
      "version": "3.11"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 5
}