Description Usage Arguments Value Note References Examples
Compute the maximum likelihood estimate, given certain elements are constrained to zero (e.g., an adjacency matrix). This approach is described in \insertCitehastie2009elements;textualIRCcheck.
1 | constrained(Sigma, adj)
|
Sigma |
Covariance matrix |
adj |
Matrix with constraints. A zero indicates that element should be constrained to zero. |
A list containing the inverse covariance matrix and the covariance matrix.
The algorithm is written in c++
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | # 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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.