Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regression Discontinuity: add ability to specify bandwidth #226

Merged
merged 6 commits into from
Jul 24, 2023

Conversation

drbenvincent
Copy link
Collaborator

@drbenvincent drbenvincent commented Jul 22, 2023

Closes #225.

  • The RegressionDiscontinuity classes (both pymc and sci-kit learn) now accept an optional bandwidth kwarg.
  • Models are only fitted to data within ±bandwidth of the threshold.
  • Docstrings are updated.
  • Tests are added.
  • The pymc and sci-kit learn docs are also updated. Closes Regression Discontinuity: improve examples #222.

@drbenvincent drbenvincent added the enhancement New feature or request label Jul 22, 2023
@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@codecov
Copy link

codecov bot commented Jul 22, 2023

Codecov Report

Merging #226 (cf64ac2) into main (90cf94b) will increase coverage by 0.85%.
The diff coverage is 95.23%.

@@            Coverage Diff             @@
##             main     #226      +/-   ##
==========================================
+ Coverage   70.40%   71.26%   +0.85%     
==========================================
  Files          19       19              
  Lines        1007     1044      +37     
==========================================
+ Hits          709      744      +35     
- Misses        298      300       +2     
Impacted Files Coverage Δ
causalpy/pymc_experiments.py 60.24% <92.85%> (+1.08%) ⬆️
causalpy/skl_experiments.py 66.86% <92.85%> (+1.86%) ⬆️
causalpy/tests/test_integration_pymc_examples.py 100.00% <100.00%> (ø)
causalpy/tests/test_integration_skl_examples.py 100.00% <100.00%> (ø)

if self.bandwidth is not None:
fmin = self.treatment_threshold - self.bandwidth
fmax = self.treatment_threshold + self.bandwidth
filtered_data = self.data.query(f"{fmin} <= x <= {fmax}")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we raise a warning when the bandwidth parameter makes the training set very small? Say less than 10 points?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice idea

@drbenvincent drbenvincent merged commit 94895b4 into main Jul 24, 2023
10 checks passed
@drbenvincent drbenvincent deleted the rd-bandwidth branch July 24, 2023 11:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Regression Discontinuity: add ability to specify bandwidth Regression Discontinuity: improve examples
2 participants