pymc-devs / pymc-experimental

https://pymc-experimental.readthedocs.io
Other
77 stars 49 forks source link

PC prior distribution for Student T dof #252

Open bwengals opened 11 months ago

bwengals commented 11 months ago

Moving this over from here.

What is this PR about?

Adding penalized complexity prior for the Student-T degrees of freedom parameter. Useful in models where the likelihood was normal, but you'd need some robustness so you switch to a Student T likelihood. It's implemented already in INLA.

The reason this is useful for modeling is you can "robustify" your Gaussian likelihood by making it a student t in a more principled way. You can use this prior to express in a meaningful way "I think there is a 50% or 20% or whatever chance that the degrees of freedom is over 30 (~normal likelihood)", whereas if you use a Gamma(2, 0.1) or worse fix the degrees of freedom to some value, you risk watering down the information coming from the data via the likelihood.

Outstanding issues

bwengals commented 10 months ago

To update where this is at, tests were passing except for windows and I couldn't figure out why. Not sure what here would depend on windows so maybe need to dig into that in a VM or something to figure that out. Definitely some room to improve how some of this is structured, but was working well enough I was comfortable using it.

ricardoV94 commented 10 months ago

@bwengals the biggest difference with Windows generally is that they sometimes default to int32 dtypes where linux defaults to int64 IIRC. Maybe something in the np.linspace overflows in windows? (I didn't look at which test was even failing, so apologies if this is completely off the target)

bwengals commented 9 months ago

overflows in windows?

Ah I bet that's it! The test produces inf and it shouldn't. Well thanks for giving me a starting place

ricardoV94 commented 9 months ago

In case that's the reason: https://stackoverflow.com/questions/36278590/numpy-array-dtype-is-coming-as-int32-by-default-in-a-windows-10-64-bit-machine

ricardoV94 commented 8 months ago

@bwengals interested in updating this one?