The `ggm_search` function performs a Metropolis-Hastings graph search to identify high-probability graph structures. At each iteration, one edge is randomly proposed to flip (add or remove, chosen by an independent coin flip), and the proposal is accepted or rejected using a proper MH acceptance ratio (including a birth-death Hastings correction for the proposal-size asymmetry between the add and remove moves), so the walk can move to a worse-BIC graph and is not just a hill-climb. It also computes an optional Bayesian Model Averaged (BMA) solution: the distinct graphs visited after burn-in are reweighted by their BIC-approximated posterior model probabilities.
ggm_search(
x,
n = NULL,
method = "mc3",
prior_prob = 0.3,
iter = 5000,
burn_in = NULL,
stop_early = 1000,
bma_mean = TRUE,
seed = NULL,
progress = TRUE,
probabilistic = TRUE,
...
)A list containing the MAP graph structure, BMA solution (if specified), and BIC-approximated posterior probabilities of the graphs visited during the search.
Data, either raw data or covariance matrix
For x = covariance matrix, provide number of observations
mc3 defaults to MH sampling
Prior prbability of sparseness.
Number of iterations
Number of initial iterations discarded before computing
the BMA solution. Defaults to iter / 2. Only meaningful when
probabilistic = TRUE (a greedy hill-climb has no transient to
burn in — its BIC trajectory is monotone non-increasing).
Default to 1000. Only used when probabilistic =
FALSE: stop the greedy search early if proposals keep being rejected
(stopping by default after 1000 consecutive rejections). Ignored under
probabilistic search, which always runs the full iter iterations
since rejections are an expected, normal part of MH sampling.
Compute Bayesian Model Averaged solution
Set seed. Current default is to set R's random seed.
Show progress bar, defaults to TRUE
Defaults to TRUE: a genuine Metropolis-Hastings sampler over graph structures (see Details). Set to FALSE for the deterministic greedy hill-climb instead.
Not currently in use
Donny Williams and Philippe Rast
Set probabilistic = FALSE to instead run a deterministic greedy
hill-climb (accept a proposed edge flip only if it improves BIC). This
is much faster per iteration but explores far less of graph space in
practice — in testing it can get stuck after accepting only a handful
of moves, well before iter is reached, and stop_early
exists to end the search once that happens.
This function is ideal for exploring the graph space and obtaining an initial estimate of the graph structure or adjacency matrix.
To refine the results or compute posterior distributions of graph parameters
(e.g., partial correlations), use the bma_posterior function,
which builds on the output of `ggm_search` to account for parameter uncertainty.
bma_posterior