Learn R Programming

BGGM (version 2.0.3)

ggm_search: Search Algorithm

Description

Search the data for promising graphs. In the case of model uncertainty, Bayesian model averaging is employed.

Usage

ggm_search(
  x,
  n = NULL,
  method = "mc3",
  prior_prob = 0.1,
  iter = 5000,
  stop_early = 1000,
  bma_mean = TRUE,
  seed = 1,
  progress = TRUE,
  ...
)

Arguments

x

Either a n by p data matrix or a p by p correlation matrix.

n

Numeric. Sample size. This is required if x is a correlation matrix.

method

Character string. Which search algorithm should be used? The default is MCMC model composition madigan1994modelBGGM.

prior_prob

Numeric. Prior inclusion probability for an individual edge. The default is 0.1 which favors graphs with less edges. If prior_prob = 0.5, this results in equal prior model probabilities.

iter

Numeric. The number of iterations (defaults to 5,000). Note that this is not the number of posterior samples, but the number of proposed graphs.

stop_early

Numeric. Should the sampler be stopped early when the graph does not change? The default is 1000 (i.e., if 1000 graphs have been rejected in a row, the search stops early).

bma_mean

Logical. Should the Bayesian model averaged mean be computed (defaults to TRUE)?

seed

An integer for the random seed (defaults to 1).

progress

Logical. Should a progress bar be included (defaults to TRUE) ?

...

Currently ignored.

Value

A list of class ggm_search. For users of BGGM, the following are the useful objects:

  • pcor_adj Selected partial correlation matrix (weighted adjacency). This corresponds to the most probable model.

  • Theta_map Selected precision matrix. This corresponds to the most probable model.

  • Theta_bma Bayesian model averaged precision matrix

  • pcor_bma Bayesian model averaged partial correlation matrix.

Details

The algorithm does not scale particularly well with p (the number of nodes).

References

Examples

Run this code
# NOT RUN {
# data
Y <- ptsd

# polychoric partials
S <- psych::polychoric(Y)$rho

# fit model
fit <- ggm_search(x = S,
                  n  = nrow(Y),
                  stop_early = 1000,
                  progress = FALSE)
# }

Run the code above in your browser using DataLab