pymc-devs / pymc-examples

Examples of PyMC models, including a library of Jupyter notebooks.
https://www.pymc.io/projects/examples/en/latest/
MIT License
280 stars 242 forks source link

HSGP: Birthdays Example #627

Closed juanitorduz closed 5 months ago

juanitorduz commented 8 months ago

Closes https://github.com/pymc-devs/pymc-examples/issues/626

Scope:

TODO:


πŸ“š Documentation preview πŸ“š: https://pymc-examples--627.org.readthedocs.build/en/627/

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

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

juanitorduz commented 8 months ago

The simple model is ready for a first round of review.

AlexAndorra commented 8 months ago

Nice @juanitorduz !! So this is an extension of your original blog post? I was gonna read when I got the time, but I might read and review this NB if that's the same and helpful to you

juanitorduz commented 8 months ago

Well, we decided with Bill that we will present a simpler model to illustrate HSGP and then Bill will add at the end the complete model from Aki. I was not able to add the Horseshoe prior (very bad r hats and divergences) in my post so Bill will give it a go :)

All feedback is welcome!

AlexAndorra commented 8 months ago

Ok, so it sounds like it's your post updated + simpler model, so I'll definitely review this PR instead! Please feel free to ping me when it's ready for review

juanitorduz commented 8 months ago

As discussed with Bill, we want to keep the model specification closer to the Stsan one for this example. In https://github.com/pymc-devs/pymc-examples/pull/627/commits/08f4bc8ac19b700206c89737dc8fa27db81f0cb4 , I changed the day_of_week parametrization from zero-sum-normal to one-hot-encoding setting Monday coefficient to zero. The relative contribution between days (say difference between Tuesday and Sunday) remained the same, it is more about the interpretation.

Remark: Note this corresponds to Model 3: Slow trend + yearly seasonal trend + day of week. In particular, if you go to the Stan code we see there is actually not an intercept as we are modeling the standardized births (vector[N] intercept = 0.0 + f_day_of_week[day_of_week], see https://github.com/avehtari/casestudies/blob/master/Birthdays/gpbf3.stan#L47C3-L47C58)

juanitorduz commented 8 months ago

@bwengals I added a small comment on the first basis vectors in https://github.com/pymc-devs/pymc-examples/pull/627/commits/67ef3fc0b7847371f23cf9d05a1f9de25dccda2a . Let me know what you think and how much you think we should expand (related to https://github.com/pymc-devs/pymc/pull/7115)

juanitorduz commented 8 months ago

In view of https://github.com/pymc-devs/pymc-examples/issues/626#issuecomment-1911777083 I think the very first iteration is ready for review in order to collect feedback.

juanitorduz commented 8 months ago

The pre-commit-ci jobs fails with a strange error. Still the pre-commit on the GitHub actions passes :)

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

View / edit / reply to this conversation on ReviewNB

bwengals commented on 2024-01-29T19:29:20Z ----------------------------------------------------------------

Given the update here I think the intro is out of date now. I would also reconsider some of the description so that it aligns with the intended audience. Would add more description of what the HSGP approximation is and when to use it. I'm not sure that "The main idea of this method relies on the Laplacian's spectral decomposition to approximate kernels' spectral measures as a function of basis functions." is going to mean much to people who aren't already very familiar with how HSGPs work.

Could also clean it up a bit, feels rough-drafty to me. Like, Vehtari's case study is described and linked to twice, was that on purpose? Should also describe that this example started in GPTools, and is now fairly easy to do in a PPL like Stan or PyMC now because of the HSGP approximation, which is pretty cool.


AlexAndorra commented on 2024-02-05T19:19:54Z ----------------------------------------------------------------

Agree with Bill

juanitorduz commented on 2024-02-13T13:11:34Z ----------------------------------------------------------------

Absolutely, I willl tackle this at the end after we have a better picture of the scope of this first iteration.