Learn R Programming

IRCcheck (version 1.0.0)

constrained: Constrained Precision Matrix

Description

Compute the maximum likelihood estimate, given certain elements are constrained to zero (e.g., an adjacency matrix). This approach is described in hastie2009elements;textualIRCcheck.

Usage

constrained(Sigma, adj)

Arguments

Sigma

Covariance matrix

adj

Matrix with constraints. A zero indicates that element should be constrained to zero.

Value

A list containing the inverse covariance matrix and the covariance matrix.

References

Examples

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

# }

Run the code above in your browser using DataLab