bayesplot icon indicating copy to clipboard operation
bayesplot copied to clipboard

Facilitating DAGs

Open bgoodri opened this issue 5 years ago • 2 comments

I'm not sure that this should actually go into bayesplot but I figure the people who would be interested and able to do something like this would read bayesplot issues.

I think it would be good if we could draw Directed Acyclic Graphs (DAGs) for models that can be represented by DAGs. We can't do that just from posterior draws or even from Stan code (in general), but I hope we could render a DAG that a user expressed (or maybe generate them from syntax in brms / rstanarm / other packages).

The ggdag package is nice but is focused on identification of causal effects rather than a description of the generative process. It doesn't seem to have a great way of representing parameters, but maybe that could be added with a PR. PyMC3 recently added something like this, although I don't like some things about the formatting. I think WinBUGS established a convention of using rectangles for observables and ovals for unobservables. Also, I'm not sure I like the foo ~ Distribution being part of the node label. Maybe we could use different colors for each node and put the distributional assumptions into the key?

Anyway, if people have other ideas, we can discuss them here.

bgoodri avatar May 17 '19 16:05 bgoodri

greta does something like this. https://greta-stats.org/articles/get_started.html#plotting

image

But I don't know how its DAG building is implemented, but the plotting uses DiagrammeR. I've used to DiagrammeR convert lavaan SEM models into graphs. DiagrammeR builds graphs from dataframes, so the main task would be to have a language that describe interrelations among model parameters and then use that build a dataframe for plotting.

tjmahr avatar May 17 '19 16:05 tjmahr

Those greta DAGs are not bad, although I don't know how tied they are to the rest of greta. The ggdag package has a formula-based interface for specifying arrows going into a node, but I don't know how easy it would be to extend that to something like y ~ normal(mu, sigma).

On Fri, May 17, 2019 at 12:57 PM TJ Mahr [email protected] wrote:

greta does something like this. https://greta-stats.org/articles/get_started.html#plotting

[image: image] https://user-images.githubusercontent.com/1890315/57943570-f6f39a00-7899-11e9-85db-fce9663cb129.png

But I don't know how its DAG building is implemented, but the plotting uses DiagrammeR http://rich-iannone.github.io/DiagrammeR/graphviz_and_mermaid.html. I've used to DiagrammeR convert lavaan SEM models into graphs. DiagrammeR builds graphs from dataframes, so the main task would be to have a language that describe interrelations among model parameters and then use that build a dataframe for plotting.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/stan-dev/bayesplot/issues/194?email_source=notifications&email_token=AAZ2XKWC7NBEDNOKTNB4PTTPV3PW3A5CNFSM4HNWZPM2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODVVJNGA#issuecomment-493524632, or mute the thread https://github.com/notifications/unsubscribe-auth/AAZ2XKXYU4KWH47ZUJPQXTTPV3PW3ANCNFSM4HNWZPMQ .

bgoodri avatar May 17 '19 21:05 bgoodri