chirunconf / chirunconf19

Discussion of potential projects for Chicago R Unconference, March 9-10, 2019
16 stars 2 forks source link

Going to/from mixed model formulas and Hasse diagrams #25

Open alexpghayes opened 5 years ago

alexpghayes commented 5 years ago

One nice way to visualize mixed models is through a Hasse diagram, as in chapter 12 of this book. We should make a tool to make these visuals easy in R, especially the notation specific to mixed effects models. It would interesting to be able to from a lme4 / brms / rstanarm model (or just the formula) to a Hasse diagram, and from a Hasse diagram to a model formula.

I wonder if this could lead to visualizations of the decomposition of variance in a multilevel model as at https://mgb-research.netlify.com/post/visualizing-variance-in-multilevel-models-using-the-riverplot-package/.

alexpghayes commented 5 years ago

Example of Hasse diagrams

image

Possible visualize decomposition of variance

image

Would also be interesting to visually differentiate flows in some way to distinguish between fixed and random effects

alexpghayes commented 5 years ago

We'd probably want to start with the balanced case and then extend to the unbalanced case.

IndrajeetPatil commented 5 years ago

This might be easy to achieve using the riverplot package. Not sure if there is a related cousin in the ggplot framework.

image

wlandau commented 5 years ago

I have enjoyed networkD3::sankeyNetwork() for Sankey diagrams. Maybe tidygraph could help bridge the gap if we want an appealing API?

tjmahr commented 5 years ago

The Hasse diagram is inscrutable, but the decomposition rivers are nice. Can we leverage D3 and r2d3 at all?

wlandau commented 5 years ago

What about the latest release of ggforce? Could geom_parallel_sets() help? Maybe ggalluvial?

benlistyg commented 5 years ago

I (kinda) did a blog post on this based on a paper by Rouder et al.

http://rpubs.com/blistyg/networksofmodels