Sampling from the posterior


Is there a good example (that I’ve missed) or good practices for sampling from the posterior after fitting with SVI in numpyro?

In particular, I guess I want to fit once, save the parameters, and then later load the parameters and sample from the guide (and even modify the guide in some cases to estimate counterfactuals). I can sort see how to do this just from the code, but I didn’t want to miss if there was standard approaches / examples (which I can’t find, it seems most examples are more interested in inferring the parameters than sampling).


Hi @jjh, for posterior predictive, we typically use numpyro.infer.Predictive class to draw samples. Your strategy sounds reasonable to me.