Automated latex equations with input of Stan model code

I was wondering if a tool exists where you input Stan model code and output a set of latex equations that describe your model, perhaps in the form you might read in an academic paper. (The reverse of this question! Translate Latex equations to Stan models)

Stan is sufficiently general and flexible that it is hard to do this for arbitrary Stan models. However, ChatGPT does a pretty good job, and therefore is probably the tool you seek. I just asked it to do this for the changepoint model from the Stan Users Guide, and it performed well:

2 Likes

That has also been my experience in going both ways: from math to Stan or from Stan to math. @mitzimorris has been experimenting with Claude Sonnet 3.7 and says it’s much better at Stan than any of the models from OpenAI available on the Plus plan (the one that’s around US$20 per month). I’m about to switch to using it for awhile to see.

I find these things often put the conditionals too high up. I’d have done a conditional on the scale of the Poisson the way I did in the example in the User’s Guide chapter on latent discrete parameters. I really like Python’s style of “a if condition else b” as opposed to the C++ style of “condition ? a : b” that we use in Stan.