rdrobust Python Library

1.3.0 · active · verified Thu Apr 16

The `rdrobust` Python library (current version 1.3.0) implements local polynomial Regression Discontinuity (RD) point estimators with robust bias-corrected confidence intervals and inference procedures. It is actively maintained and regularly updated, with releases typically aligning with new features or improvements to the underlying R/C++ codebase it wraps.

Common errors

Warnings

Install

Imports

Quickstart

This example simulates data for a regression discontinuity design around a cutoff at `c=0`. It then applies the `rdrobust` function to estimate the treatment effect at the cutoff using the default robust bias-corrected method. It demonstrates preparing data as Pandas Series and accessing the structured output object's summary.

import numpy as np
import pandas as pd
import rdrobust as rd

# Simulate data for a regression discontinuity design
np.random.seed(123)
n = 500
# Running variable 'x' from -1 to 1
x = np.random.uniform(-1, 1, n)
# Outcome 'y' with a jump at x=0 (the cutoff)
y = 3 + 2 * x + 4 * (x >= 0) + np.random.normal(0, 1, n)

# Convert to pandas Series, which is a common and robust input format
y_series = pd.Series(y)
x_series = pd.Series(x)

# Apply rdrobust with the cutoff c=0
# The output 'r' is an rdrobust.rdrobust_output object
r = rd.rdrobust(y_series, x_series, c=0)

# Print a summary of the results
print("\nRD Robust Results:")
print(r.summary())

# You can also access individual components, e.g., the point estimate
# print(f"Point Estimate: {r.estimate[0]}")

view raw JSON →