The R package bgms provides tools for Bayesian analysis of
the ordinal Markov random field (MRF), a graphical model describing networks
of binary and/or ordinal variables MarsmanVandenBerghHaslbeck_2025bgms.
The likelihood is approximated via a pseudolikelihood, and Markov chain Monte
Carlo (MCMC) methods are used to sample from the corresponding pseudoposterior
distribution of model parameters.
The main entry points are:
bgm: estimation in a one-sample design.
bgmCompare: estimation and group comparison in an independent-sample design.
Both functions support Bayesian effect selection with spike-and-slab priors.
In one-sample designs, bgm models the presence or absence of
edges between variables. Posterior inclusion probabilities quantify the
plausibility of each edge and can be converted into Bayes factors for
conditional independence tests.
bgm can also model communities (clusters) of variables. The
posterior distribution of the number of clusters provides evidence for or
against clustering SekulovskiEtAl_2025bgms.
In independent-sample designs, bgmCompare estimates group
differences in edge weights and category thresholds. Posterior inclusion
probabilities quantify the evidence for differences and can be converted
into Bayes factors for parameter equivalence tests
MarsmanWaldorpSekulovskiHaslbeck_2024bgms.
The package also provides:
Simulation of response data from MRFs with a Gibbs sampler
(simulate_mrf).
Posterior estimation and edge selection in one-sample designs
(bgm).
Posterior estimation and group-difference selection in
independent-sample designs (bgmCompare).
For tutorials and worked examples, see:
vignette("intro", package = "bgms") — Getting started.
vignette("comparison", package = "bgms") — Model comparison.
vignette("diagnostics", package = "bgms") — Diagnostics and
spike-and-slab summaries.
Maintainer: Maarten Marsman m.marsman@uva.nl (ORCID)
Authors:
Don van den Bergh (ORCID)
Other contributors: