pymc-labs / pymc-labs/CausalPy
regression discontinuity: allow the treatment to be `>=` or `<=` the threshold
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.2k
- Forks
- 115
- Avg merge
- 6d 1h
- Merged PRs (30d)
- 11
Description
At the moment, the assumption is that the units above the threshold are treated. But this absolutely is not always going to be true. So we need to allow for this.
Option 1: Setting a threshold_function='<=' or threshold_function='>='
Option 2: allow users to use a kwarg where they can override a function. Eg. threshold_function=np.greater_equal or threshold_function =np.less_equal
Do this on the synthetic regression discontinuity datasets, for both PyMC and skl. Append it as another analysis example.
Things to think about:
- Helper function
_is_treatedusesnp.greater_equal - We have a
treatedcolumn in the dataset. This presents some redundancy because all we need is the running variable and the_is_treatedhelper function. That function is there because we need a way of working out which data are treated when we interpolate forxpred. One solution would be to removetreatedas a column of data and instead derive this from the running variable and_is_treated. However, thetreatedstill needs to appear in the model formula. So would have to add some explanatory text in notebooks. - The order of comparison to calculate
discontinuity_at_threshold - Would be a good idea opportunity to add some input validation for RD (see #78)
- Update the integration tests
[Optional] Do we want to add in a shaded region above/below the treatment threshold?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the synthetic regression discontinuity datasets for the PyMC and skl implementations, especially the _is_treated helper and discontinuity_at_threshold calculation. Review the notebooks and integration tests; done means both implementations support either comparison direction, the examples explain the treatment column, and the integration tests cover the new behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, scikit-learn
- Domain
- data, machine-learning
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100