pymc-labs / pymc-labs/CausalPy

regression discontinuity: allow the treatment to be `>=` or `<=` the threshold

Open
#12 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
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_treated uses np.greater_equal
  • We have a treated column in the dataset. This presents some redundancy because all we need is the running variable and the _is_treated helper function. That function is there because we need a way of working out which data are treated when we interpolate for xpred. One solution would be to remove treated as a column of data and instead derive this from the running variable and _is_treated. However, the treated still 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.