Fitting Stan our using Stan_model and then sampling

Hello Everyone,

To evaluate my stan model I would like to calculate Bias, Root mean squared error, coverage probability etc. To do this I need replicates.
Should I be using the “stan” function outside of a for loop and using the “sampling” command or should I be using the “stan” function inside the loop to fit the model. My concern is if the seed is random. Are both approaches equivalent? I do know that when using the “stan” function inside of a loop it causes R to recompile.

Thank you for the help!

1 Like

For repeated fitting of the same model, it is recommended to use stan_model to compile once and then sampling in the loop. Seed is different for each sampling run unless you explicitly set it when calling sampling.

Best of luck!

1 Like