Skip to content

leostimpfle/pyrdd

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pyrdd

pyrdd provides estimation and inference procedures for regression discontinuity designs (RDD). It is a refactor of the excellent rdrobust with a focus on performance, compatibility and maintainability.

Note

pyrdd is tested for correctness against rdrobust but still in early development and its API is subject to change.

Main features

  • performance: pyrdd is orders of magnitudes faster than rdrobust
  • compatibility: pyrdd has minimal dependencies and is compatible with numpy >= 2.0
  • maintainability: pyrdd is tested against rdrobust, uses modern Python tooling and is fully type-checked

Benchmarks

Getting started

Estimate a sharp RD with automatic bandwidth selection:

import numpy as np
from pyrdd.discontinuity import fit
from pyrdd.bandwidth import select_bandwidth

# Create sample data
rng = np.random.default_rng(0)
x = rng.uniform(-1, 1, 500)  # running variable
y = (x >= 0) + 0.5 * x + rng.normal(size=500)  # outcome with jump at 0

# Estimate RDD with robust bias-corrected inference and MSE optimal bandwidth
result = fit(y=y, x=x, c=0.0, bwselect="mserd")
# Inspect results
print(result.robust.coefficient)  # bias-corrected estimate
print(result.conventional.coefficient)  # conventional estimate
print(result.robust.standard_error)  # robust standard error 

# It is also possible to estimate optimal bandwidth independently
bandwidth = select_bandwidth(y=y, x=x, c=0.0, bwselect="mserd")
print(bandwidth.h)  # main bandwidth (left, right)

About

Fast local polynomial RD estimation with robust bias-corrected inference

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages