Skip to main content

State of the Art RD Packages For Python

Installation

Please note that installation should be done with a mixture of pip and direct installations in R so that the correct versions of packages are installed.

With pip for python: pip install py_rdpackages

Important: you need to have the original rdrobust installed in R: install.packages('rdrobust')

Notes:

  • rdrobust requires the newest version of ggplot2 so please: install.packages('ggplot2')
  • The rdrobust and ggplot2 versions in Anaconda lag behind the current release for R. Please install in R directly as opposed to through conda.

Introduction and Use

These packages are a work in progress, but are an attempt to create a wrapper to implement the wonderful RD packages found here (https://sites.google.com/site/rdpackages/rdrobust) which utilize R or Stata, so that they can be used in Python directly.

I utilize the graphics package of Seaborn to make the plots look nice and to enable additional features, like binning points by size.

There are three packages in py_rdpackages:

  1. rdplot creates plots of the regression discontinuity with a variety of options.
  2. rdrobust does the RD and reports the regression results.
  3. rdbwselect selects the optimal bandwidth size.

A Example of the Output

The code in the testing folder produces the following example.

Alt text

Requirements and Stability

Use of the programs requires all of the following packages in Python:

  1. rpy2 for running R in Python
  2. matplotlib and seaborn for producing high quality graphics
  3. pandas, numpy and for data manipulation and dataframe reading

Currently tested and stable for:

  • rdrobust version 0.99.9
  • rpy2 version 2.9.4 (last version updated through conda -- may work for later versions)
  • ggplot2 version 3.3.0

Limitations

  1. ryp2 produced slow pandas DF to R DF conversions, so I use pd.df.to_csv('temp_file_for_rd.csv') as a solution and then delete that same file after doing the analysis. This should be fixed in future versions.
  2. Of course, Python calling R and then converting back to python is not ideal. Some future version should code this from scratch.

Metadata

Release files for py-rdpackages 1.0.3

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

Source distribution (sdist)

Source distribution for py-rdpackages 1.0.3
File Size Uploaded Provenance Actions
py_rdpackages-1.0.3.tar.gz 12.2 kB Without provenance Details for py_rdpackages-1.0.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for py-rdpackages 1.0.3
File Interpreter ABI Platform Actions
py_rdpackages-1.0.3-py3-none-any.whl Python 3 none any Details for py_rdpackages-1.0.3-py3-none-any.whl

Total release size: 35.4 kB

Release files / py_rdpackages-1.0.3.tar.gz

Download URL py_rdpackages-1.0.3.tar.gz
Size 12.2 kB
Tags Source
SHA-256 checksum
How to use checksums
7f07498940144141cdb7bf29b8cb4c25619b773273dea1afccf6fb6b7d7b86eb
BLAKE2b-256 checksum
How to use checksums
ed3a219f77095d3dc3887315987e640968b27c4da4f63d4a528a701193e7250c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.24.0 setuptools/50.3.1.post20201107 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.2

Release files / py_rdpackages-1.0.3-py3-none-any.whl

Download URL py_rdpackages-1.0.3-py3-none-any.whl
Size 23.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
37350ba9c81f722cf55cb418085738581be1728fa8ac8e9ec5153b7fd110fc86
BLAKE2b-256 checksum
How to use checksums
b0adc86fe729ef0b1f4efa60b1e32939f0d700e10c1355eb3f9e4bd0861f72b3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.24.0 setuptools/50.3.1.post20201107 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.2

Security for py-rdpackages 1.0.3

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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