Honest inference in regression discontinuity designs
Project description
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 electionsload_cghs(): Oreopoulos (2006) UK general household surveyload_rcp(): Battistin et al. (2009) retirement consumption puzzleload_headst(): Ludwig & Miller (2007) Head Start programload_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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file rdhonest-0.0.1.tar.gz.
File metadata
- Download URL: rdhonest-0.0.1.tar.gz
- Upload date:
- Size: 1.3 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cd8295ec328ea1d962610b3a847b7d1bba5eb23f51ae0bfdad71b253bb903a91
|
|
| MD5 |
b84ea9093d4d910123f4440438d5f126
|
|
| BLAKE2b-256 |
1938c944078e1d6709a87ae199187424ccf9f8a3dac06c98f6c5e6b57434a196
|
Provenance
The following attestation bundles were made for rdhonest-0.0.1.tar.gz:
Publisher:
publish.yml on anzonyquispe/RDHonest
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rdhonest-0.0.1.tar.gz -
Subject digest:
cd8295ec328ea1d962610b3a847b7d1bba5eb23f51ae0bfdad71b253bb903a91 - Sigstore transparency entry: 855334924
- Sigstore integration time:
-
Permalink:
anzonyquispe/RDHonest@87caead26ef9c2145330759ab69c60013471d1ad -
Branch / Tag:
refs/tags/v0.0.1 - Owner: https://github.com/anzonyquispe
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@87caead26ef9c2145330759ab69c60013471d1ad -
Trigger Event:
push
-
Statement type:
File details
Details for the file rdhonest-0.0.1-py3-none-any.whl.
File metadata
- Download URL: rdhonest-0.0.1-py3-none-any.whl
- Upload date:
- Size: 1.3 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0202c2e803cd11be903f6a3fe0c68220165e012586fd3a341eda4f6aa05b00a7
|
|
| MD5 |
2b2bc7f8fc88c478d7cbb711194fb04b
|
|
| BLAKE2b-256 |
544ae16bf70188cdb97aba8ee47176840813b98400b75a9803beddce431fdc2a
|
Provenance
The following attestation bundles were made for rdhonest-0.0.1-py3-none-any.whl:
Publisher:
publish.yml on anzonyquispe/RDHonest
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rdhonest-0.0.1-py3-none-any.whl -
Subject digest:
0202c2e803cd11be903f6a3fe0c68220165e012586fd3a341eda4f6aa05b00a7 - Sigstore transparency entry: 855334945
- Sigstore integration time:
-
Permalink:
anzonyquispe/RDHonest@87caead26ef9c2145330759ab69c60013471d1ad -
Branch / Tag:
refs/tags/v0.0.1 - Owner: https://github.com/anzonyquispe
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@87caead26ef9c2145330759ab69c60013471d1ad -
Trigger Event:
push
-
Statement type: