pymc-labs / CausalPy

A Python package for causal inference in quasi-experimental settings
https://causalpy.readthedocs.io
Apache License 2.0
881 stars 63 forks source link

Bayesian power analysis #276 #277

Closed cetagostini closed 7 months ago

cetagostini commented 10 months ago

Hey everyone!

As we discussed in issue #276, I've added a new function to CausalPy that performs power analysis. This is based on my internal work on estimating effects and conducting sensitivity analysis within Bayesian frameworks.

What will you find?

  1. Notebook
  2. Code example

I hope this explanation makes sense. Ideally, I'd like to have a few rounds of feedback and answer any questions you may have before moving on to unit testing.

Looking forward to hearing your thoughts!

cc: @drbenvincent

review-notebook-app[bot] commented 10 months ago

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

drbenvincent commented 9 months ago

FYI: I changed the filename of the notebook to snake case and I also update the pre-commits to use the --fix flag for nbqa-ruff. So this has modified the notebook a little - mainly just removing redundant imports I believe.

More from me soon...

drbenvincent commented 9 months ago

In terms of the failing doctest, I ran these locally and they failed. Then re-build the environment and they passed. So perhaps there's just a version issue here. Will let you know if I figure out something more definitive.

drbenvincent commented 9 months ago

Remote failing tests should hopefully be fixed whenever https://github.com/pymc-devs/pytensor/pull/550 is fixed and make its way into a new pytensor release. Or when https://github.com/pymc-labs/CausalPy/issues/279 is resolved. So don't sink any effort into trying to fix failing remote tests right now. You can of course ensure that all local tests pass - they are not affected by the issue. Not on my machine anyway.

codecov[bot] commented 9 months ago

Codecov Report

Attention: 9 lines in your changes are missing coverage. Please review.

Comparison is base (70de921) 76.27% compared to head (c534c55) 77.40%.

Files Patch % Lines
causalpy/pymc_experiments.py 89.04% 8 Missing :warning:
causalpy/utils.py 90.90% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #277 +/- ## ========================================== + Coverage 76.27% 77.40% +1.12% ========================================== Files 20 20 Lines 1332 1425 +93 ========================================== + Hits 1016 1103 +87 - Misses 316 322 +6 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

drbenvincent commented 9 months ago

Remote tests seem to be passing now :) Give me a shout whenever you manage to work on updates @cetagostini :)

cetagostini commented 9 months ago

Hey hey @drbenvincent, All the pre-commits are working on my side, except one related to ´pkg_resources´.

Let me know, if extra changes are needed.

cetagostini commented 7 months ago

@drbenvincent Starting this week to add the changes requested 🚀