irc_ggm: Irrepresentable Condition: Gaussian Graphical Model

Description Usage Arguments Value References Examples

View source: R/irc_ggm.R

Description

Check the IRC (or Incoherence condition) in Gaussian graphical Models, following Equation (8) in \insertCiteravikumar2008modelIRCcheck.

Usage

1
irc_ggm(true_network, cores = 2)

Arguments

true_network

A matrix of dimensions p by p, assumed to be a partial correlation matrix.

cores

Integer. Number of cores for parallel computing (defaults to 2)

Value

infinity norm (greater than 1 the IRC is violated, with closer to zero better).

References

\insertAllCited

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# generate network
net <- gen_net(p = 20, edge_prob = 0.3, lb = 0.05, ub = 0.3)

# check irc
irc_ggm(net$pcors)

# random adj 
# 90 % sparsity (roughly)
p <- 20
adj <- matrix(sample(0:1, size = p^2, replace = TRUE, 
              prob = c(0.9, 0.1) ), 
              nrow = p, ncol = p)

adj <- symm_mat(adj)

diag(adj) <- 1

# random correlation matrix
set.seed(1)
cors <- cov2cor(
  solve(
  rWishart(1, p + 2, diag(p))[,,1])
)

# constrain to zero
net <- constrained(cors, adj = adj)

irc_ggm(net$wadj)


#' # random adj 
# 50 % sparsity (roughly)
p <- 20
adj <- matrix(sample(0:1, size = p^2, replace = TRUE, prob = c(0.5, 0.5) ), 
              nrow = p, ncol = p)

adj <- symm_mat(adj)
diag(adj) <- 1

# random correlation matrix
set.seed(1)
cors <- cov2cor(
  solve(
  rWishart(1, p + 2, diag(p))[,,1])
)

# constrain to zero
net <- constrained(cors, adj = adj)

irc_ggm(net$wadj)

IRCcheck documentation built on April 9, 2021, 9:08 a.m.