Given a precision matrix (K) and a fixed undirected graph (G),
returns the precision matrix constrained to the graph's structure, so that
entries at non-edges are (numerically) zero. Uses the node-wise regression algorithm.
Usage
constrain_precision_to_graph(K, G, tol = 1e-06, itermax = 1000)
Arguments
- K
A \(p \times p\) symmetric positive-definite precision matrix.
- G
A \(p \times p\) symmetric adjacency matrix with 0/1 entries; the
zero pattern defines the conditional-independence constraints.
- tol
Convergence tolerance for the iterative solver.
- itermax
Maximum number of iterations.
Value
A \(p \times p\) precision matrix with zeros at the non-edges of G.
Examples
p <- 3
G <- matrix(0, p, p)
G[1, 2] <- G[2, 1] <- 1 # only 1-2 is an edge
K <- diag(p)
K[1, 2] <- K[2, 1] <- 0.3
K[1, 3] <- K[3, 1] <- 0.05 # numerical noise at a non-edge
Kc <- constrain_precision_to_graph(K, G)
Kc[1, 3] # ~ 0
#> [1] 0