11
22<!-- README.md is generated from Readme.Rmd. Please edit that file -->
33
4- <!-- # bgms <a href="https://bayesiangraphicalmodeling.com"><img src="man/figures/bgms_sticker.svg" height="200" align="right" alt="bgms website" /></a> -->
5-
6- <div style =" display :flex ; align-items :center ; justify-content :space-between ;" >
7-
8- <h1 >
9-
10- bgms
11- </h1 >
12-
13- <a href =" https://bayesiangraphicalmodeling.com " >
14- <img src =" man/figures/bgms_sticker.svg " height =" 200 " alt =" bgms website " />
15- </a >
16-
17- </div >
4+ ![ bgms] ( man/figures/bgms-banner.svg )
185
196<!-- badges: start -->
207
@@ -29,209 +16,82 @@ stable](https://img.shields.io/badge/lifecycle-stable-brightgreen.svg)](https://
2916
3017** Bayesian analysis of graphical models**
3118
32- The ** bgms** package implements Bayesian estimation and model comparison
33- for graphical models of binary, ordinal, continuous, and mixed variables
34- (<span class =" nocase " >Marsman, van den Bergh, et al.</span >, 2025). It
35- supports ** ordinal Markov random fields (MRFs)** for discrete data,
36- ** Gaussian graphical models (GGMs)** for continuous data, and ** mixed
37- MRFs** that combine discrete and continuous variables in a single
38- network. The likelihood is approximated with a pseudolikelihood, and
39- Markov chain Monte Carlo (MCMC) methods are used to sample from the
40- corresponding pseudoposterior distribution of the model parameters.
19+ The ** bgms** package provides Bayesian estimation and edge selection for
20+ Markov random field models of mixed binary, ordinal, and continuous
21+ variables. The variable types in the data determine the model: an
22+ ** ordinal MRF** for ordinal data, a ** Gaussian graphical model** for
23+ continuous data, or a ** mixed MRF** combining both. Posterior inference
24+ uses Markov chain Monte Carlo, combining a Metropolis approach for
25+ between-model moves (i.e., edge selection) with the No-U-Turn sampler
26+ for within-model parameter updates. The package supports both
27+ single-threaded and parallel chains, and uses a C++ backend for
28+ computational efficiency.
4129
4230## Main functions
4331
44- The package has two main entry points:
45-
46- - ` bgm() ` – estimates a single network in a one-sample design. Use
47- ` variable_type = "ordinal" ` for an MRF, ` "continuous" ` for a GGM, or a
48- per-variable vector mixing ` "ordinal" ` , ` "blume-capel" ` , and
49- ` "continuous" ` for a mixed MRF.
50- - ` bgmCompare() ` – compares networks between groups in an
51- independent-sample design.
52-
53- ## Effect selection
54-
55- Both functions support ** effect selection** with spike-and-slab priors:
56-
57- - ** Edges in one-sample designs** : ` bgm() ` models the presence or
58- absence of edges between variables. Posterior inclusion probabilities
59- indicate the plausibility of each edge and can be converted into Bayes
60- factors for conditional independence tests (see
61- <span class =" nocase " >Marsman, van den Bergh, et al.</span >, 2025;
62- <span class =" nocase " >Sekulovski et al.</span >, 2024).
63-
64- - ** Communities/clusters in one-sample designs** : ` bgm() ` can also model
65- community structure. Posterior probabilities for the number of
66- clusters quantify the plausibility of clustering solutions and can be
67- converted into Bayes factors (see Sekulovski et al., 2025).
68-
69- - ** Group differences in independent-sample designs** : ` bgmCompare() `
70- models differences in edge weights and category thresholds between
71- groups. Posterior inclusion probabilities indicate the plausibility of
72- parameter differences and can be converted into Bayes factors for
73- tests of parameter equivalence (see Marsman, Waldorp, et al., 2025).
74-
75- ## Learn more
32+ - ` bgm() ` — estimate a graphical model in a one-sample design.
33+ - ` bgmCompare() ` — compare graphical models between groups.
7634
77- For worked examples and tutorials, see the package vignettes:
35+ Both functions support ** edge selection** via spike-and-slab priors,
36+ yielding posterior inclusion probabilities for each edge. ` bgm() ` can
37+ additionally model ** community structure** , and ` bgmCompare() ` can test
38+ for ** group differences** in individual parameters.
7839
79- - [ Getting
80- Started] ( https://bayesian-graphical-modelling-lab.github.io/bgms/articles/intro.html )
81- - [ Model
82- Comparison] ( https://bayesian-graphical-modelling-lab.github.io/bgms/articles/comparison.html )
83- - [ Diagnostics and Spike-and-Slab
84- Summaries] ( https://bayesian-graphical-modelling-lab.github.io/bgms/articles/diagnostics.html )
40+ ## Installation
8541
86- You can also access these directly from R with :
42+ Install from CRAN :
8743
8844``` r
89- browseVignettes (" bgms" )
45+ install.packages (" bgms" )
9046```
9147
92- ## Why use Markov Random Fields?
93-
94- Graphical models or networks have become central in recent psychological
95- and psychometric research (Contreras et al., 2019; Marsman & Rhemtulla,
96- 2022; Robinaugh et al., 2020). Most are ** Markov random field (MRF)**
97- models, where the graph structure reflects partial associations between
98- variables (Kindermann & Snell, 1980).
99-
100- In an MRF, a missing edge between two variables implies ** conditional
101- independence** given the rest of the network (Lauritzen, 2004). In other
102- words, the remaining variables fully explain away any potential
103- association between the unconnected pair.
104-
105- ## Why use a Bayesian approach?
106-
107- When analyzing an MRF, we often want to compare competing hypotheses:
108-
109- - ** Edge presence vs. edge absence** (conditional dependence
110- vs. independence) in one-sample designs.
111- - ** Parameter difference vs. parameter equivalence** in
112- independent-sample designs.
113-
114- Frequentist approaches are limited in such comparisons: they can reject
115- a null hypothesis, but they cannot provide evidence * for* it. As a
116- result, when an edge or difference is excluded, it remains unclear
117- whether this reflects true absence or simply insufficient power.
118-
119- Bayesian inference avoids this problem. Using ** inclusion Bayes
120- factors** (<span class =" nocase " >Huth et al.</span >, 2023;
121- <span class =" nocase " >Sekulovski et al.</span >, 2024), we can quantify
122- evidence in both directions:
123-
124- - ** Evidence of edge presence** vs. ** evidence of edge absence** , or
125- - ** Evidence of parameter difference** vs. ** evidence of parameter
126- equivalence** .
127-
128- This makes it possible not only to detect structure and group
129- differences, but also to conclude when there is an * absence of
130- evidence* .
131-
132- ## Installation
133-
134- The current developmental version can be installed with
48+ Or install the development version from GitHub:
13549
13650``` r
137- if (! requireNamespace(" remotes" )) {
138- install.packages(" remotes" )
139- }
51+ # install.packages("remotes")
14052remotes :: install_github(" Bayesian-Graphical-Modelling-Lab/bgms" )
14153```
14254
143- ## References
144-
145- <div id="refs" class="references csl-bib-body hanging-indent"
146- entry-spacing="0" line-spacing="2">
147-
148- <div id =" ref-ContrerasEtAl_2019 " class =" csl-entry " >
149-
150- Contreras, A., Nieto, I., Valiente, C., Espinosa, R., & Vazquez, C.
151- (2019). The study of psychopathology from the network analysis
152- perspective: A systematic review. * Psychotherapy and Psychosomatics* ,
153- * 88* (2), 71–83. < https://doi.org/10.1159/000497425 >
154-
155- </div >
156-
157- <div id =" ref-HuthEtAl_2023_intro " class =" csl-entry " >
158-
159- <span class =" nocase " >Huth, K., de Ron, J., Goudriaan, A. E., Luigjes,
160- K., Mohammadi, R., van Holst, R. J., Wagenmakers, E.-J., & Marsman,
161- M.</span > (2023). Bayesian analysis of cross-sectional networks: A
162- tutorial in R and JASP. * Advances in Methods and Practices in
163- Psychological Science* , * 6* , 1–18.
164- < https://doi.org/10.1177/25152459231193334 >
165-
166- </div >
167-
168- <div id =" ref-KindermannSnell1980 " class =" csl-entry " >
169-
170- Kindermann, R., & Snell, J. L. (1980). * Markov random fields and their
171- applications* (Vol. 1). American Mathematical Society.
172-
173- </div >
174-
175- <div id =" ref-Lauritzen2004 " class =" csl-entry " >
55+ ## Citation
17656
177- Lauritzen, S. L. (2004). * Graphical models * . Oxford University Press.
57+ If you use bgms in your work, please cite:
17858
179- </div >
59+ 1 . Marsman, M., van den Bergh, D., & Haslbeck, J. M. B. (2025).
60+ Bayesian analysis of the ordinal Markov random field.
61+ * Psychometrika* , * 90* (1), 146–182.
62+ [ DOI:10.1017/psy.2024.4] ( https://doi.org/10.1017/psy.2024.4 )
18063
181- < div id = " ref-MarsmanRhemtulla_2022_SIintro " class = " csl-entry " >
64+ Related methodological papers:
18265
183- Marsman, M., & Rhemtulla, M. (2022). Guest editors’ introduction to the
184- special issue “network psychometrics in action”: Methodological
185- innovations inspired by empirical problems. * Psychometrika* , * 87* , 1–11.
186- < https://doi.org/10.1007/s11336-022-09861-x >
66+ 2 . Sekulovski, N., Keetelaar, S., Huth, K. B. S., Wagenmakers, E.-J.,
67+ van Bork, R., van den Bergh, D., & Marsman, M. (2024). Testing
68+ conditional independence in psychometric networks: An analysis of
69+ three Bayesian methods. * Multivariate Behavioral Research* , * 59* ,
70+ 913–933.
71+ [ DOI:10.1080/00273171.2024.2345915] ( https://doi.org/10.1080/00273171.2024.2345915 )
18772
188- </div >
73+ 3 . Marsman, M., Waldorp, L. J., Sekulovski, N., & Haslbeck, J. M. B.
74+ (2025). Bayes factor tests for group differences in ordinal and
75+ binary graphical models. * Psychometrika* , * 90* (5), 1809–1842.
76+ [ DOI:10.1017/psy.2025.10060] ( https://doi.org/10.1017/psy.2025.10060 )
18977
190- <div id =" ref-MarsmanVandenBerghHaslbeck_2025 " class =" csl-entry " >
78+ 4 . Sekulovski, N., Arena, G., Haslbeck, J. M. B., Huth, K. B. S.,
79+ Friel, N., & Marsman, M. (2025). A stochastic block prior for
80+ clustering in graphical models.
81+ [ PsyArXiv:29p3m] ( https://osf.io/preprints/psyarxiv/29p3m_v1 )
19182
192- <span class =" nocase " >Marsman, M., van den Bergh, D., & Haslbeck, J. M.
193- B.</span > (2025). Bayesian analysis of the ordinal Markov random field.
194- * Psychometrika* , * 90* (1), 146–182. < https://doi.org/10.1017/psy.2024.4 >
83+ You can also retrieve the citation from R:
19584
196- </div >
197-
198- <div id =" ref-MarsmanWaldorpSekulovskiHaslbeck_2024 " class =" csl-entry " >
199-
200- Marsman, M., Waldorp, L. J., Sekulovski, N., & Haslbeck, J. M. B.
201- (2025). Bayes factor tests for group differences in ordinal and binary
202- graphical models. * Psychometrika* , * 90* (5), 1809–1842.
203- < https://doi.org/10.1017/psy.2025.10060 >
204-
205- </div >
206-
207- <div id =" ref-RobinaughEtAl_2020 " class =" csl-entry " >
208-
209- Robinaugh, D. J., Hoekstra, R. H. A., Toner, E. R., & Borsboom, D.
210- (2020). The network approach to psychopathology: A review of the
211- literature 2008–2018 and an agenda for future research. * Psychological
212- Medicine* , * 50* , 353–366. < https://doi.org/10.1017/S0033291719003404 >
213-
214- </div >
215-
216- <div id =" ref-SekulovskiEtAl_2025 " class =" csl-entry " >
217-
218- Sekulovski, N., Arena, G., Haslbeck, J. M. B., Huth, K. B. S., Friel,
219- N., & Marsman, M. (2025). A stochastic block prior for clustering in
220- graphical models. * Retrieved from
221- <a href="https://osf.io/preprints/psyarxiv/29p3m_v1 "
222- class="uri">Https://Osf.io/Preprints/Psyarxiv/29p3m_v1 </a >* .
223-
224- </div >
85+ ``` r
86+ citation(" bgms" )
87+ ```
22588
226- < div id = " ref-SekulovskiEtAl_2024 " class = " csl-entry " >
89+ ## Contributing
22790
228- <span class =" nocase " >Sekulovski, N., Keetelaar, S., Huth, K. B. S.,
229- Wagenmakers, E.-J., van Bork, R., van den Bergh, D., & Marsman,
230- M.</span > (2024). Testing conditional independence in psychometric
231- networks: An analysis of three Bayesian methods. * Multivariate
232- Behavioral Research* , * 59* , 913–933.
233- < https://doi.org/10.1080/00273171.2024.2345915 >
91+ Contributions are welcome. See [ CONTRIBUTING.md] ( CONTRIBUTING.md ) for
92+ how to get started.
23493
235- </ div >
94+ ## Code of Conduct
23695
237- </div >
96+ This project follows the [ Contributor Covenant Code of
97+ Conduct] ( CODE_OF_CONDUCT.md ) .
0 commit comments