Using Stan for non-modelling purposes

Is it possible to use Stan for non-modelling purposes, i.e. for other things than estimating parameters in a model?
For example, generating draws from some distribution, convex optimization problems given data, numerical integration etc.
If yes, how?

Thanks!

yes, this can and should be done. here’s a nice blog post showing you how to do it:

3 Likes

Thanks for this!

I see how this works for drawing samples from posterior, but what about using Stan for optimization and numerical integration?

if I understand your question correctly, optimization can be done using Stan’s optimizers -

see https://mc-stan.org/docs/reference-manual/optimization-algorithms-chapter.html
and https://mc-stan.org/docs/docs/cmdstan-guide/optimization.html

numerical integration? not quite sure what you mean - Stan has a 1D integrator function, which has been discussed in other threads here - https://mc-stan.org/docs/functions-reference/functions-1d-integrator.html

It depends on what kind of numerical integration I suppose. In some sense that’s the main purpose of Stan (MCMC is numerical integration).