A Pythonic Package for Regression Discontinuity
Project description
State of the Art RD Packages For Python
Installation
In terminal window:
pip install py_rdpackages
In R:
install.packages('rdrobust')
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.
There are three packages in py_rdpackages
:
rdplot
creates plots of the regression discontinuity with a variety of options.rdrobust
does the RD and reports the regression results.rdbwselect
selects the optimal bandwidth size.
Requirements
Use of the programs requires all of the following packages in Python:
rpy2
for running R in Pythonmatplotlib
andseaborn
for producing high quality graphicspandas
,numpy
andstatsmodels
for data manipulation and dataframe reading
Important: you need to have the original rdrobust
installed in R (you can find this in the above link).
Limitations
ryp2
produced slow pandas DF to R DF conversions, so I usepd.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.- I have not written a full set of graphics options for the RD plots. Future versions will allow you to use all of the classic
matplotlib
tools, and also turn on/off the vertical line and change the coloring of the scatterplot. Also, I do not incorporate standard errors on the scatterplot bins, which would be easy enough to add. In this version, if you want to do some of those things, you should do them after making a function call. - Of course, Python calling R and then converting back to python is not ideal. Some future version should get the original C implementation of the code and just work from there.
Hopefully I will make these better in the future, but for now let me know if you spot any bugs.
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
Hashes for py_rdpackages-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 94b434a17f94d707e46244b445e5208a5426ecddc7fe79f06713ad0b6ed976b1 |
|
MD5 | fc64b4d9c270777df29a31542816e394 |
|
BLAKE2b-256 | f573bd4a952735dcb61de4b9e8293eb15e95a0f75c9efc8e6ac7b3a8405047fe |