{
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "# Chapter 30: Regression Discontinuity\n",
        "**Economic question:** What can a policy cutoff reveal about causal effects near the threshold?\n",
        "\nRDD compares units just above and below a threshold where treatment assignment changes discontinuously.\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {},
      "outputs": [],
      "source": [
        "import numpy as np, statsmodels.api as sm\n",
        "rng=np.random.default_rng(30); x=rng.uniform(-1,1,1000); d=(x>=0).astype(int); y=2+.8*x+2*d+rng.normal(0,.5,1000)\n",
        "mask=np.abs(x)<=.35; X=sm.add_constant(np.c_[x[mask],d[mask],x[mask]*d[mask]])\n",
        "print(sm.OLS(y[mask],X).fit().params)\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Interpretation checklist\n",
        "- State the unit of observation and units of every variable.\n",
        "- Separate association, prediction, and causation.\n",
        "- Report magnitude and uncertainty.\n",
        "- Identify the most important threat to validity.\n"
      ]
    }
  ],
  "metadata": {
    "kernelspec": {
      "display_name": "Python 3",
      "language": "python",
      "name": "python3"
    },
    "language_info": {
      "name": "python",
      "version": "3.13"
    },
    "ceteris_lab": {
      "course_slug": "fundamentals-python-econometrics",
      "course_title": "Fundamentals of Python for Financial Econometrics",
      "chapter": 30,
      "source_origin": "supplied"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 5
}
