Compiling a (simple) model graph (the DAG) to a Stan (or BUGS) program

Does anyone know of tools that can take in a model graph (the DAG specifying all the conditional distributions) and at least in simple enough cases, compile the graph into a Stan/BUGS/… model?

If I were to write one - would anyone have advice on how to go about doing this?

What language do you intend to write the graph in? I think the sort of cheeky/obnoxious answer here is that you could just write the graph in Stan… in fact, BUGS is quite literally a language for specifying the DAG. Stan is a bit more flexible, but retains that capability.

So, there’s a UI/DSL that I’m working with that outputs a graph. I could write the parser in python or R?

How’s the DAG specified? I suppose one can turn a dagitty DAG specification into a brms formula, with additional information of data, parameters, etc.

I wish for a tool in the opposite direction: turn Stan code or brms formula into DAGs. It’d help model diagnostics and demonstration.

At the moment, it’s a list of nodes with some metadata (e.g. rv name, data type, range) and edges (rv to rv and what the conditional distributions are).

The suggestion of converting the DAGs to brms-type formulae is an excellent one! I think it might be perfect for the restricted subset of models that I’m currently using.

I believe this is what blavaan does.