The R
package bgms provides tools for a Bayesian analysis of graphical models describing networks of variables. The package uses Bayesian variable selection methods to model the underlying network structure. The methods are organized around two general approaches for Bayesian variable selection: (1) EM variable selection and (2) Gibbs variable selection. The key distinction is that the former uses a continuous spike and slab prior distribution on the pairwise interactions (Marsman et al. 2022) that allows us to use EM variable selection (Ročková and George 2014). The Gibbs variable selection approach (George and McCulloch 1993), on the other hand, stipulates a discrete spike and slab prior on the pairwise interactions, which allows us to set the interactions to exact zeroes. To account for the discontinuity at zero, we embed a Metropolis approach for mixtures of mutually singular distributions (Gottardo and Raftery 2008) in a Gibbs sampler. The goal is to provide these tools for Markov Random Field (MRF) models for a wide range of variable types in the bgms package, and it currently provides them for analyzing networks of binary and/or ordinal variables (Marsman and Haslbeck 2023).
Why use Markov Random Fields?
Multivariate analysis using graphical models has received much attention in the recent psychological and psychometric literature (Robinaugh et al. 2020; Marsman and Rhemtulla 2022; Steinley 2021; Contreras et al. 2019). Most of these graphical models are Markov Random Field (MRF) models, whose graph structure reflects the conditional associations between variables (Kindermann and Snell 1980). In these models, a missing edge between two variables in the network implies that these variables are independent, given the remaining variables (Lauritzen 2004). In other words, the remaining variables of the network fully account for the potential association between the unconnected variables.
Why use a Bayesian approach to analyze the MRF?
Testing the structure of the MRF requires us to determine the plausibility of the opposing hypotheses of conditional dependence and conditional independence. For example, how plausible are network structures that include the edge between variables 3 and 9 compared to network structures that exclude this edge? Frequentist approaches are limited in this respect, because they can only reject the conditional independence hypothesis, but not support it (Wagenmakers et al. 2018; Wagenmakers 2007). This creates the problem that, if an edge is excluded, we do not know whether this is because the edge is absent in the population, or because we lack the power to reject the null hypothesis of independence. To avoid this problem, we will use a Bayesian approach using Bayes factors (Kass and Raftery 1995). The inclusion Bayes factor (Huth et al. 2023) allows us to quantify how much the data support both conditional dependence —evidence of edge presence— or conditional independence —evidence of edge absence. It also allows us to conclude that there is only limited support for either hypothesis (Dienes 2014) —an absence of evidence.
Installation
You can install the latest version from CRAN using:
install.packages("bgms")
The current developmental version can be installed with
if (!requireNamespace("remotes")) {
install.packages("remotes")
}
remotes::install_github("MaartenMarsman/bgms")