A measure of uncertainty

It is common place in psychological networks to compute “confidence” intervals. This can also be done in BGGM. In a Bayesian context, they are called credible intervals. Note the intepretation also differs between confidence and credible intervals, but that is not something I discuss here (see google search).

Fit Model

First fit the model.

# data
Y <- BGGM::bfi[,1:5]

# sample posterior
fit <- estimate(Y, analytic = FALSE,
iter = 5000)

Summarize the Posterior Distributions

Next summarize the partial correlations.

summary_fit <- summary(fit, cred = 0.90)

# print
summary_fit
#> BGGM: Bayesian Gaussian Graphical Models
#> ---
#> Posterior Samples: 5000
#> Observations (n): 2709
#> Variables (p): 5
#> Edges: 10
#> ---
#> Call:
#> estimate(Y = Y, iter = 5000, analytic = FALSE)
#> ---
#> Estimates:
#>
#>  Edge Estimate Est.Error Cred.lb Cred.ub
#>  1--2   -0.240     0.018  -0.270  -0.210
#>  1--3   -0.108     0.019  -0.139  -0.076
#>  2--3    0.286     0.017   0.257   0.315
#>  1--4   -0.007     0.019  -0.040   0.024
#>  2--4    0.165     0.019   0.134   0.195
#>  3--4    0.178     0.019   0.147   0.208
#>  1--5   -0.009     0.019  -0.041   0.023
#>  2--5    0.156     0.019   0.126   0.186
#>  3--5    0.359     0.017   0.331   0.386
#>  4--5    0.122     0.019   0.090   0.154
#> ---

Plot the Posterior Distributions

summary_plot <- plot(summary_fit)

Plot Customization

The object summary_plot can then be further customized. The following is a simple example.

library(ggplot2)

# plot
plot(summary_fit, width = 0) +
# flip
coord_flip() +
# change the theme
theme_bw() +
# remove legend
theme(legend.position = "none",
panel.grid  = element_blank()) +
scale_color_manual(values = c("#999999", "#CC79A7")) 
When there are many partial correlations, it might be useful to add scale_x_discrete(labels = NULL) which will remove the names.