Function Reference
Documentation for the bgms API.
Complete documentation for all exported functions.
bgm() and bgmCompare() return S7 objects (classes bgms and bgmCompare). Standard methods like print(), summary(), and coef() work through S3 dispatch for compatibility with base R generics.
Core Functions
| Function | Description |
|---|---|
bgm() |
Estimates the main effects and pairwise interactions of a network using a Bayesian framework. |
bgmCompare() |
Estimates whether edge weights and category thresholds differ across networks of two different groups. |
Prior Samplers
Draw from the model’s priors before seeing data, for prior visualization and simulation studies.
| Function | Description |
|---|---|
sample_ggm_prior() |
Prior sampler for the GGM precision matrix (conditional, joint, or hierarchical specification). |
sample_graph_prior() |
Prior sampler for the edge-inclusion indicators and edge-prior hyperparameters. |
sample_sbm_prior() |
Ancestral sampler for the stochastic block model hyperprior (allocations, pair probabilities). |
Prior Constructors
Prior specification objects passed to bgm() and bgmCompare() via the interaction_prior, threshold_prior, means_prior, precision_scale_prior, edge_prior, and difference_prior arguments.
| Constructor | Family | Used for |
|---|---|---|
cauchy_prior() |
Cauchy(0, scale) | Interactions, thresholds, means |
normal_prior() |
Normal(0, scale) | Interactions (bgm() and bgmCompare() default), thresholds, means |
beta_prime_prior() |
Beta-prime | Thresholds (default), interactions |
gamma_prior() |
Gamma(shape, rate or eta) | Precision-matrix diagonal |
exponential_prior() |
Exponential(rate or eta) | Precision-matrix diagonal (default) |
bernoulli_prior() |
Bernoulli | Edge / difference inclusion (default) |
beta_bernoulli_prior() |
Beta-Bernoulli | Edge / difference inclusion |
sbm_prior() |
Stochastic Block Model | Edge / difference inclusion |
Methods
| Method | Description |
|---|---|
print() |
Minimal console output for a fitted model |
summary() |
Summary statistics for posterior samples |
coef() |
Extract posterior means of model parameters |
plot() |
Draw the fitted model: the edge evidence plot by default, or posterior centrality |
plot_edge_posterior() |
Draw one edge’s posterior against its prior, with the inclusion evidence as a probability wheel |
predict() |
Predict new observations from a fitted model |
simulate() |
Simulate datasets from the posterior distribution |
simulate_mrf() |
Simulate observations from a Markov Random Field (mrfSampler() is the deprecated former name) |
Diagnostics
Post-fit checks on a model you have already estimated.
| Function | Description |
|---|---|
verdicts() |
Read each edge’s inclusion Bayes factor as a presence / undecided / absence verdict, and flag the verdicts a longer run could change. |
calibration_check() |
Reliability diagrams of the model’s conditional predictions, with the consistency band a calibrated model wanders inside. |
prior_sensitivity_check() |
Recover each edge’s inclusion Bayes factor curve across the slab scale and classify which verdicts depend on it. |
summarize_zratio_gauge() |
Trust gauge for the hierarchical graph prior’s fast normalizer approximation. |
Extractor Functions
| Function | Description |
|---|---|
extract_arguments() |
Retrieve the arguments used when fitting a model |
extract_main_effects() |
Extract main-effect parameters: posterior means for bgms fits, posterior samples for bgmCompare fits |
extract_pairwise_interactions() |
Extract posterior samples of partial association parameters |
extract_centrality() |
Evaluate strength centrality on every posterior draw, giving each node’s centrality posterior; summary() and plot() read it |
extract_indicators() |
Extract posterior samples of edge or difference indicators |
extract_posterior_inclusion_probabilities() |
Compute posterior inclusion probabilities, from the Rao-Blackwellized draws by default or from the raw indicator samples |
extract_prior_inclusion_probabilities() |
Compute prior inclusion probabilities, matched in shape to the posterior ones for Bayes factor computation |
extract_inclusion_bf() |
Compute inclusion Bayes factors from the Rao-Blackwellized odds accumulators, on the Bayes factor scale by default or on the log scale with log = TRUE; finite for saturated edges up to the numerical bound |
extract_indicator_priors() |
Retrieve the indicator prior specification (prior type and hyperparameters) |
extract_group_params() |
Extract group-specific parameters from a bgmCompare fit |
extract_sbm() |
Extract stochastic block model assignments and probabilities |
extract_ess() |
Compute effective sample sizes for model parameters; for indicators, the Rao-Blackwellized ESS |
extract_rhat() |
Compute split-R-hat convergence diagnostics |
extract_precision() |
Extract posterior mean precision matrix (GGM / continuous block) |
extract_partial_correlations() |
Extract posterior mean partial correlation matrix |
extract_log_odds() |
Extract posterior mean log-odds matrix (OMRF / discrete block) |
Datasets
| Dataset | N | Items | Type | Description |
|---|---|---|---|---|
ADHD |
355 | 18 | Binary | ADHD symptom ratings for children |
Boredom |
986 | 8 | Ordinal | Boredom proneness scores (7-point Likert) |
Wenchuan |
362 | 17 | Ordinal | PTSD symptom ratings (5-point Likert) |