Extractor Functions

Functions to extract specific components from fitted bgms and bgmCompare objects.

Unless noted otherwise, extractor functions use one argument:

extract_arguments

Retrieve the arguments used when fitting a model with bgm() or bgmCompare().

extract_arguments(bgms_object)

Returns a named list containing all arguments passed to the fitting function, including data dimensions, prior settings, and MCMC configuration.

extract_main_effects

Retrieve posterior mean main-effect parameters.

extract_main_effects(bgms_object)

The structure depends on the model type:

  • GGM (bgms): NULL. GGM models have no main effects.
  • OMRF (bgms): A numeric matrix (p x max_categories) of posterior mean category thresholds. Columns beyond the number of categories for a variable are NA.
  • Mixed MRF (bgms): A list with $discrete (threshold matrix) and $continuous (means matrix).
  • bgmCompare: A matrix with one row per post-warmup iteration, containing posterior samples of baseline main-effect parameters.

extract_pairwise_interactions

Retrieve posterior samples of partial association parameters.

extract_pairwise_interactions(bgms_object)

Returns a matrix with one row per post-warmup iteration and one column per edge. For bgmCompare, columns correspond to baseline partial association parameters.

extract_indicators

Retrieve posterior samples of inclusion indicators.

extract_indicators(bgms_object)

Returns a matrix with one row per post-warmup iteration and one column per indicator, containing binary (0/1) samples:

  • bgms: One column per edge. Requires edge_selection = TRUE.
  • bgmCompare: Columns for main-effect and pairwise difference indicators. Requires difference_selection = TRUE.

extract_posterior_inclusion_probabilities

Compute posterior inclusion probabilities.

extract_posterior_inclusion_probabilities(bgms_object)

Returns a symmetric p x p matrix of posterior inclusion probabilities:

  • bgms: Off-diagonal entries are edge inclusion probabilities. Requires edge_selection = TRUE.
  • bgmCompare: Diagonal entries are main-effect inclusion probabilities; off-diagonal entries are pairwise difference inclusion probabilities. Requires difference_selection = TRUE.

extract_indicator_priors

Retrieve the prior specification used for inclusion indicators.

extract_indicator_priors(bgms_object)

Returns a named list describing the prior structure, including the prior type and hyperparameters:

  • bgms: Requires edge_selection = TRUE. Returns the prior type ("Bernoulli", "Beta-Bernoulli", or "Stochastic-Block") and associated hyperparameters.
  • bgmCompare: Requires difference_selection = TRUE. Returns the difference prior specification.

extract_group_params

Compute group-specific parameter estimates by combining baseline parameters and group differences.

extract_group_params(bgms_object)

bgms_object must be a fitted bgmCompare object.

Returns a list with main_effects_groups (main effects per group) and pairwise_effects_groups (pairwise effects per group).

extract_sbm

Retrieve posterior summaries from a model fitted with the Stochastic Block prior.

extract_sbm(bgms_object)

bgms_object must be a fitted bgms object.

Requires edge_selection = TRUE and edge_prior = "Stochastic-Block". Returns a list with:

  • posterior_num_blocks — Posterior probabilities for each possible number of clusters.
  • posterior_mean_allocations — Posterior mean cluster allocations.
  • posterior_mode_allocations — Posterior mode cluster allocations.
  • posterior_mean_coclustering_matrix — Co-clustering proportion matrix.

extract_ess

Retrieve effective sample size estimates for all parameters.

extract_ess(bgms_object)

Returns a named list with ESS values for each parameter type present in the model (e.g., main, pairwise, indicator). ESS is computed in C++ using the AR spectral density method, matching coda::effectiveSize. For implementation details, see the Technical Manual.

extract_rhat

Retrieve R-hat convergence diagnostics for all parameters.

extract_rhat(bgms_object)

Returns a named list with R-hat values for each parameter type present in the model (e.g., main, pairwise, indicator). R-hat is computed in C++ using the Gelman-Rubin formula, matching coda::gelman.diag. For implementation details, see diagnostics in the Technical Manual.

Deprecated functions

  • extract_category_thresholds() — Renamed to extract_main_effects().
  • extract_edge_indicators() — Renamed to extract_indicators().
  • extract_pairwise_thresholds() — Renamed to extract_main_effects().

extract_precision

Retrieve the posterior mean precision matrix.

extract_precision(bgms_object)

bgms_object must be a fitted bgms object (GGM or mixed MRF).

Returns a symmetric p x p matrix (or the continuous block submatrix for mixed MRFs) containing the posterior mean precision matrix \(\boldsymbol{\Theta}\).

extract_partial_correlations

Retrieve the posterior mean partial correlation matrix.

extract_partial_correlations(bgms_object)

bgms_object must be a fitted bgms object (GGM or mixed MRF).

Returns a symmetric matrix of partial correlations, computed by standardizing the precision matrix: \(\rho_{ij} = -\Theta_{ij} / \sqrt{\Theta_{ii} \Theta_{jj}}\).

extract_log_odds

Retrieve the posterior mean log-odds matrix.

extract_log_odds(bgms_object)

bgms_object must be a fitted bgms object (OMRF or mixed MRF).

Returns a symmetric matrix of log adjacent-category odds ratios. For the ordinal MRF, \(\text{log-odds}_{ij} = 2 \omega_{ij}\).

See also

bgm(), bgmCompare(), Methods