-
-
Notifications
You must be signed in to change notification settings - Fork 127
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
Initial attempt to add support for the Laplace family #524
Conversation
…ent with the numpy implementation) rather than 'b' (which is what pymc uses)
@markgoodhead thanks for opening this PR! Initially this looks good! The only issue I would address is the name of the scale parameter in the Laplace distribution. In some places you're using Edit it would be good to have a short example in this PR to see this new family in action :) Edit 2: From your commit messages I see you previously had |
@markgoodhead for the missing Lines 267 to 295 in 762f30a
|
Thanks very much @tomicapretto ! I'll have a look at those changes now. I also spotted there's some interaction with the centered/non-centered functionality going on here for the Normal link case: Lines 134 to 150 in 762f30a
From my experiments before the Laplace link has similar trade-offs to the Normal in terms of when to use the centered/non-centered parameterisation so perhaps this would also need modifying to switch between Normal and Laplace to implement both the centered/non-centered versions of both? |
On this point - it looks like Laplace won't need any special casing so I wouldn't need to do any changes here? In which case I think the outstanding changes would be a) the example you requested (I assume you mean a notebook in the examples folder?) and b) whatever changes you suggest to ensure compatibility with the |
Good catch! This is not an adjustment that happens only for the Normal family (i.e. using Normal likelihood function). This happens for all group-specific effects (i.e. the ones you get with |
Ah yes of course - my mistake! In that case I think the only change outstanding is the example you requested. I took a look at the notebooks in the example folder and they each seem like quite detailed explanations of a particular type of statistical technique, whereas this is sort of more 'minor' (just another family) so I'm not sure if it's appropriate for me just to add a very small notebook here or if there's a better place the example should live? |
No need to add a notebook at this time.. Just something like the Bambi example in this PR #490 |
I agree that there is no need to add a notebook as part of this PR, opening an issue as a remainder that the example is missing should be enough. Additionally, instead of writing a new notebook, we can maybe extend this one https://bambinos.github.io/bambi/main/notebooks/t_regression.html |
OK I've got a similar example that (appears to me anyway) to work on this branch - is this what you were expecting?
|
I forgot to add that it would be good to have a test for this new family. Something like the examples attached would be good for now bambi/bambi/tests/test_built_models.py Lines 546 to 548 in 762f30a
bambi/bambi/tests/test_built_models.py Lines 461 to 463 in 762f30a
|
Yes good idea, I've added one now based on a modified version of my example |
Codecov Report
@@ Coverage Diff @@
## main #524 +/- ##
==========================================
- Coverage 86.78% 86.69% -0.09%
==========================================
Files 32 32
Lines 2573 2586 +13
==========================================
+ Hits 2233 2242 +9
- Misses 340 344 +4
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for this contribution! I hope it was a nice experience to you too.
If I can ask one more thing it would be comments about how easy/hard it was to work through this PR and what we could do to help you. Thanks again!
Sure - I can't think of anything big that'd change to make the process easier. There's always friction learning a new codebase but this wasn't too bad - the code is well laid out and generally quite readable. Only two quite minor things I can think of - you can add the guidelines (which mention black and pylint) to be displayed on a PR as you open it (or a link to them) as I didn't spot those until quite late. Also, I got caught when my version of black was too old and did some bad formatting, perhaps the versions of pylint and black used in github actions could be specified in the PR guidelines? |
@markgoodhead thanks for the feedback. I'll open an issue so we can update our guidelines. The versions of black and pylint are in |
This is to address #523
Note this is a WIP as I attempt to learn more of the bambi internals.
I'm not very familiar with the codebase but I attempted to copy the format of the Normal family and modify it accordingly. One thing I couldn't quite see is how this interacts with pymc - there's no "pm.Normal" calls which I was expecting to modify to the Laplace equivalent. Please let me know if there's something I'm missing and I'll attempt to fix this up.