rct

generate robust and balanced random assignements

https://github.com/sylvaingchassang/rct

Science Score: 23.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
  • .zenodo.json file
  • DOI references
    Found 1 DOI reference(s) in README
  • Academic publication links
  • Committers with academic emails
    1 of 3 committers (33.3%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (12.0%) to scientific vocabulary
Last synced: 11 months ago · JSON representation

Repository

generate robust and balanced random assignements

Basic Info
  • Host: GitHub
  • Owner: sylvaingchassang
  • License: mit
  • Language: Jupyter Notebook
  • Default Branch: master
  • Homepage:
  • Size: 91.8 KB
Statistics
  • Stars: 6
  • Watchers: 1
  • Forks: 1
  • Open Issues: 3
  • Releases: 0
Created almost 7 years ago · Last pushed about 5 years ago
Metadata Files
Readme License

README.md

rct

Build Status

What this package does

This package provides tools to generate robust and balanced random assignments following Banerjee, Chassang, Montero, and Snowberg (2019).

The RCT, KRerandomizedRCT, and QuantileTargetingRCT classes of the rct.design module implement RCT, K-rerandomized RCT, and Quantile Targeting RCT designs described in Banerjee, Chassang, Montero, and Snowberg (2019).

For each design, assignment_from_iid draws designs selected from i.i.d. assignments; assignment_from_shuffled draws designs selected from exchangeable assignments guaranteed to exactly match desired sampling weights (up to integer issues).

The package allows for an arbitrary number of treatment arms, specified via the weights argument in each design.

rct implements various balance objectives, including:
- minimizing the Mahalanobis distance between the mean of selected covariates across treatment arms;
- maximizing the minimum p-value for the regression of covariates on treatment dummies;
- soft blocking on selected covariates;
- linear combinations of existing objectives.

Customizing balance objectives, besides linear combinations of existing balance functions, is straightforward. First, you can pass different aggregating functions to the BalanceObjective constructor. For instance, this would allow to maximize the mean p-value rather than the minimum p-value. Second, you can simply define a new class inheriting from BalanceObjective and implementing the abstract method _balance_func.

Citation

To cite rct in publications, use
Banerjee, Abhijit, Sylvain Chassang, Sergio Montero, and Erik Snowberg. A theory of experimenters. NBER Working Paper No. w23867. National Bureau of Economic Research, 2017. The corresponding bibtex entry is:
@techreport{NBERw23867, title = "A Theory of Experimenters", author = "Banerjee, Abhijit and Chassang, Sylvain and Montero, Sergio and Snowberg, Erik", institution = "National Bureau of Economic Research", type = "Working Paper", series = "Working Paper Series", number = "23867", year = "2017", month = "September", doi = {10.3386/w23867}, URL = "http://www.nber.org/papers/w23867", abstract = {This paper proposes a decision-theoretic framework for experiment design. We model experimenters as ambiguity-averse decision-makers, who make trade-offs between subjective expected performance and robustness. This framework accounts for experimenters' preference for randomization, and clarifies the circumstances in which randomization is optimal: when the available sample size is large enough or robustness is an important concern. We illustrate the practical value of such a framework by studying the issue of rerandomization. Rerandomization creates a trade-off between subjective performance and robustness. However, robustness loss grows very slowly with the number of times one randomizes. This argues for rerandomizing in most environments.}, }

Installation

This package is tested for python 3.6 and python 3.7 under Ubuntu Linux 16.04.

You may download the package via pip:

$ pip install rct

this will install all required dependencies.

Alternatively, if you want to use recent updates, you can clone (git@github.com:sylvaingchassang/rct.git) or download a .zip of the repo. If you do so you must install requirements for the package manually. With pip, run

./rct$ pip install -r requirements.txt

Running tests

Before using the package, you may want to check that unit and integration tests pass on your machine. To this end, run

./rct$ pytest --cov=. --cov-report=term-missing

Examples

Example notebooks illustrate the use of rct modules: - rct/notebooks/examples_rct.ipynb shows how to generate traditional i.i.d. and shuffled RCT assignments for binary and ternary treatments. The pvalue_report function provides a useful summary of assignment balance by reporting the (#treatments -1, #covariates) matrix of p-values obtained from regressing covariates on different treatment dummies.

Integration tests located at rct/tests/test_integration.py replicate the content of these notebooks.

Contribute

If you want to improve rct please reach out!

Whether you are a programmer who wants to improve our code, or an experiment designer with a practical comment, or a new design idea, we want to talk to you!

On our current todo list (2019/09/20):
- adding type hints to improve readability;
- profiling & speed improvement;
- implementing sequential designs.

Owner

  • Name: sylvain chassang
  • Login: sylvaingchassang
  • Kind: user
  • Location: Princeton, NJ

Professor of Economics | Princeton & NBER

GitHub Events

Total
Last Year

Committers

Last synced: almost 3 years ago

All Time
  • Total Commits: 59
  • Total Committers: 3
  • Avg Commits per committer: 19.667
  • Development Distribution Score (DDS): 0.085
Past Year
  • Commits: 0
  • Committers: 0
  • Avg Commits per committer: 0.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
sylvain chassang s****g@g****m 54
fcsylvain s****n@f****m 3
Lars Vilhuber l****r@c****u 2
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 12 months ago

All Time
  • Total issues: 3
  • Total pull requests: 2
  • Average time to close issues: N/A
  • Average time to close pull requests: 10 minutes
  • Total issue authors: 1
  • Total pull request authors: 2
  • Average comments per issue: 0.0
  • Average comments per pull request: 0.0
  • Merged pull requests: 2
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • sylvaingchassang (3)
Pull Request Authors
  • sylvaingchassang (1)
  • larsvilhuber (1)
Top Labels
Issue Labels
Pull Request Labels

Packages

  • Total packages: 1
  • Total downloads:
    • pypi 38 last-month
  • Total dependent packages: 0
  • Total dependent repositories: 1
  • Total versions: 2
  • Total maintainers: 1
pypi.org: rct

design robust balanced randomized experiments

  • Versions: 2
  • Dependent Packages: 0
  • Dependent Repositories: 1
  • Downloads: 38 Last month
Rankings
Dependent packages count: 10.0%
Stargazers count: 20.3%
Dependent repos count: 21.7%
Average: 22.1%
Forks count: 22.6%
Downloads: 35.8%
Maintainers (1)
Last synced: 12 months ago

Dependencies

requirements.txt pypi
  • jupyterlab >=1.1.4
  • lazy-property >=0.0.1
  • numpy >=1.17.2
  • pandas >=0.25.1
  • parameterized >=0.7.0
  • pytest >=5.1.2
  • pytest-cov >=2.7.1
  • statsmodels >=0.10.1