Skip to main content

RDHonest - Python

Honest and efficient confidence intervals in regression discontinuity designs.

This is a Python port of the R package RDHonest by Michal Kolesár and Timothy B. Armstrong.

Installation

pip install rdhonest

Or install from source:

pip install -e .

Quick Start

import rdhonest as rdh
import numpy as np

# Load example data
lee08 = rdh.load_lee08()

# Sharp RD with uniform kernel
results = rdh.rd_honest(
    Y=lee08['voteshare'].values,
    X=lee08['margin'].values,
    cutoff=0,
    kern="uniform",
    M=0.1,
    h=10
)
print(results)

# Or use R-style formula interface
results = rdh.RDHonest(
    formula="voteshare ~ margin",
    data=lee08,
    cutoff=0,
    kern="triangular",
    M=0.1,
    h=10
)

Features

  • Sharp and Fuzzy RD: Support for both sharp and fuzzy regression discontinuity designs
  • Honest Inference: Bias-aware confidence intervals that are valid under smoothness assumptions
  • Optimal Bandwidth Selection: MSE, FLCI, and OCI criteria
  • Multiple Kernels: Triangular, Epanechnikov, Uniform, and Optimal kernels
  • Smoothness Bounds: Estimate lower bounds on the smoothness constant M
  • BME Class: Support for bounded misspecification error function class
  • Clustering: Cluster-robust standard errors
  • Covariates: Covariate adjustment support

Main Functions

rd_honest / RDHonest

Main function for honest inference in RD designs.

results = rdh.rd_honest(
    Y,              # Outcome variable
    X,              # Running variable
    cutoff=0,       # RD cutoff
    M=None,         # Smoothness constant (uses ROT if None)
    kern="triangular",  # Kernel type
    h=None,         # Bandwidth (optimal if None)
    opt_criterion="MSE",  # Bandwidth criterion
    se_method="nn", # SE estimation method
    alpha=0.05,     # Significance level
    sclass="H",     # Smoothness class: "H" (Holder) or "T" (Taylor)
)

rd_honest_bme / RDHonestBME

Honest CIs for discrete running variables under BME class.

cghs = rdh.load_cghs()
results = rdh.rd_honest_bme(
    Y=np.log(cghs['earnings'].values),
    X=cghs['yearat14'].values,
    cutoff=1947,
    h=3,
    order=1
)

cvb / CVb

Critical values for biased Gaussian estimators.

# 95% critical value with bias B=1
cv = rdh.cvb(B=1, alpha=0.05)

# Standard 95% critical value (no bias)
cv = rdh.cvb(B=0)

rd_scatter / RDScatter

Binned scatterplot for RD visualization.

import matplotlib.pyplot as plt

lee08 = rdh.load_lee08()
ax = rdh.rd_scatter(
    Y=lee08['voteshare'].values,
    X=lee08['margin'].values,
    cutoff=0,
    avg=50
)
plt.show()

Included Datasets

  • load_lee08(): Lee (2008) US House elections
  • load_cghs(): Oreopoulos (2006) UK general household survey
  • load_rcp(): Battistin et al. (2009) retirement consumption puzzle
  • load_headst(): Ludwig & Miller (2007) Head Start program
  • load_rebp(): Lalive (2008) Austrian unemployment duration

References

  • Armstrong, T.B. and Kolesár, M. (2018). Optimal inference in a class of regression models. Econometrica, 86(2):655-683.

  • Armstrong, T.B. and Kolesár, M. (2020). Simple and honest confidence intervals in nonparametric regression. Quantitative Economics, 11(1):1-39.

  • Kolesár, M. and Rothe, C. (2018). Inference in regression discontinuity designs with a discrete running variable. American Economic Review, 108(8):2277-2304.

License

GPL-3.0

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Metadata

Release files for rdhonest 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for rdhonest 0.0.1
File Size Uploaded
rdhonest-0.0.1.tar.gz 1.3 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for rdhonest 0.0.1
File Interpreter ABI Platform
rdhonest-0.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 2.5 MB

Release files / rdhonest-0.0.1.tar.gz

Download URL rdhonest-0.0.1.tar.gz
Size 1.3 MB
Tags Source
SHA-256 checksum
How to use checksums
cd8295ec328ea1d962610b3a847b7d1bba5eb23f51ae0bfdad71b253bb903a91
BLAKE2b-256 checksum
How to use checksums
1938c944078e1d6709a87ae199187424ccf9f8a3dac06c98f6c5e6b57434a196
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jan 26, 2026.

Transparency log

Release files / rdhonest-0.0.1-py3-none-any.whl

Download URL rdhonest-0.0.1-py3-none-any.whl
Size 1.3 MB
Tags Python 3
SHA-256 checksum
How to use checksums
0202c2e803cd11be903f6a3fe0c68220165e012586fd3a341eda4f6aa05b00a7
BLAKE2b-256 checksum
How to use checksums
544ae16bf70188cdb97aba8ee47176840813b98400b75a9803beddce431fdc2a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jan 26, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page