Visualizing the Estimated Structure(s)

In the paper (see the reference section), we introduced an innovative graphing strategy for Gaussian graphical models. The basic idea is to have three separate “networks”: (1) the conditional independence structure; (2) the conditional dependence structure; and (3) an inconclusive network that includes relations in which there was not positive evidence in either direction.

To ease the implementation, the R package BGGM includes a shiny application. This essentially streamlines the process and the only coding required is importing the data into R. The end result is a publication quality plot. Furthermore, the user-friendly interface allows for visualizing the uncertainty in the estimated network structures.

Estimate the Network

# the data
Y <- subset(iri, select = - gender)

# fit the model
fit <- explore(Y, prior_sd = 0.10, 
               iter = 5000)

Note that Y is the example data and prior_sd is the prior distribution used in the paper.

Launch the Shiny App

The next step is to launch the shiny app.

shiny_bggm(fit, 
           node_groups = BGGM:::iri_labels, 
           node_outer_size = 9, 
           node_inner_size = 7, 
           node_labels_color = "white", 
           edge_multiplier = 5,
           txt_size = 5,
           alpha = 0.5)

Only fit is needed to launch the shiny app. The additional arguments are passed to the plotting function plot.select.explore.

There is a place to slide the Bayes factor threshold and the hypothesis can be specified (e.g., a one-sided test). This will dynamically change the network plots. And there a button that can be pressed to save the plot. Here is an example screenshot, where the Bayes factor threshold is set to 3. This is interpreted as the data being (at least) 3 times as likely under either hypothesis (e.g., \(H_0: \rho_{ij} = 0\) vs. \(H_1: \rho_{ij} > 0\)).

Screenshot

Screenshot

And here is another screenshot with a different Bayes factor threshold.
Screenshot

Screenshot

Note that, with the Bayes factor threshold set to 10, now the inconclusive “network” features more connections. And the conditional independence structure is completely empty. A non-arbitrary choice is not possible in this case. Hence the reason we suggested to visualize all three structures, as opposed to only the estimated conditional dependence structure.

By pressing the save button, the plot is saved as bggm_plot.pdf.

Note that the plot can be further customized by passing arguments to the shiny_bggm function. To do so, see the document ion for the function plot.select.explore. For changing the ggplot object directly, it will be better to work directly with R. There are examples in the BGGM documentation browseVignettes("BGGM").

We emphasize that this application is most useful for visualizing the underlying uncertainty of the estimated structures. And note that it would be a mistake to think the estimated structures reflect the true network. Rather, even if a true network existed and we somehow measured it, then at best we merely have what was detected which is influenced by many factors (e.g., sample size, effect size, etc.).