Generate predictions from pyStan after model fit in Stan 3

There is no extract function in stan 3. How would I generate predictions with confidence intervals with the new APIs (without doing directly in the stan code)?

Check example from PyStan — pystan 3.7.0 documentation how to access variables.

You can also use ArviZ InferenceData to access your sample.

https://python.arviz.org/en/stable/api/generated/arviz.from_pystan.html#arviz.from_pystan

Thanks for the info, but it may be complicated to do it manually in Python. Are there utilities to automatically do it? If not, is there a trick to add “generated quantities” later?

I think cmdstanpy has a wrapper for it, not sure if pystan had.

cc.

@WardBrian @mitzimorris

PyStan only runs the NUTS-HMC sampler.

CmdStanPy exposes all methods in CmdStan, including standalone generated quantities: API Reference — CmdStanPy 1.1.0 documentation

The extract function is implemented in CmdStanPy as functions stan_variable and stan_variables: API Reference — CmdStanPy 1.1.0 documentation