Learn R Programming

IRCcheck (version 1.0.0)

irc_ggm: Irrepresentable Condition: Gaussian Graphical Model

Description

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

Usage

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

Examples

Run this code
# NOT RUN {
# 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)

# }

Run the code above in your browser using DataLab