How to use a fitted stan model for production (get posterior predictive distributions) in python

Using fitted stan model with rstan for production in python

Hello, I am pretty new to stan, I have fitted a model which I coded in stan with rstan, in this model I have already used generated quantities in the stan code to get predictive distributions on some test data, now I am wondering if I can use use the trained model as a python function in order to draw new simulations for new data?

Thank you

Hi, @saya and welcome to the Stan forums. I somehow missed your question last week. The answer is yes, you can do that using standalone generated quantities. I’d recommend CmdStanPy—here’s its doc for standalone generated quantities:

https://mc-stan.org/cmdstanpy/users-guide/examples/Run%20Generated%20Quantities.html

1 Like