fehiepsi / rethinking-numpyro

Statistical Rethinking (2nd ed.) with NumPyro

Home Page:https://fehiepsi.github.io/rethinking-numpyro/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Quadratic approximation results diverge

tomwallis opened this issue · comments

In Chapter 2, code section 2.6 (2nd Edition), McElreath reports quadratic approximation values of

p 0.67   0.16 0.42  0.92

On my machine (numpyro 0.11.0, jax 0.4.10) I get

 p      0.63      0.13      0.43      0.83

Are these numerical differences to be expected? I do not have any experience with numpyro and not much with quadratic approximation, but I'm surprised at the divergence for this 1D problem. McElreath's solution is also more accurate to the true proportion.

Hi @tomwallis the behavior is intended because in numpyro, we perform laplace approximation in unconstrained space. If we do approximation as in constrained space as in the book, the samples of p (generated by a gaussian distribution) might be invalid (because p belongs to (0, 1) domain).

How about making a feature request in numpyro to support laplace approximation in constrained domain? I'm not sure how to deal with invalid samples... probably just simply do reject sampling on them.

I see, thank you for clarifying!