Tool to auto-generate model diagrams?


Shot in the dark, but a reviewer asked for a diagram of my model, and while I could do one by hand I thought I’d check if anyone knows any tools that attempt to automate some portion of that task. Obviously a hard problem, but figured it might be common enough that someone might have tried to tackle it.



Greta does this. It’s about midway down here under Plotting:



Ah, my model was done in Stan; presumably no automatic Stan-to-Greta converters too?



No but they do offer help for translating from Stan to Greta:



I think it’d be about the same amount of work to convert (and check) the code as it would be to do then diagram by hand.



Yeah I think the (most?) interesting aspect to Greta is using TensorFlow to fit probability models in R.



The diagrams to which you refer are for specifying probabilistic graphical models. The Stan Modeling Language, on the other hand, is richer than just probabilistic graphical models which means that we cannot define diagrams for a general Stan program. Moreover, in turns out to be theoretically impossible to translate those limited Stan programs that are equivalent to graphical models to a graphical model and hence graphical model representations like diagrams. Heuristic translations can go a long way, but given the tricky edge cases no one has attempted anything along this line.



Came across this nice new R-package for visualizing DAGS yesterday thanks to @bgoodri which may have been helpful to you: ggdag. The video content is here: It’s not auto-generating but it could be the best alternative in R at the moment. What did you end up using?

1 Like