regul_glasso | R Documentation |
Use the graphical lasso algorithm to regularize a square symmetric matrix (e.g. a covariance or correlation matrix) by assuming that its inverse has many zeros.
regul_glasso(
mat,
lambda,
maxiter_outer = 200,
maxiter_lasso = 200,
tol = 1e-04,
verbose = FALSE
)
mat |
A square symmetric matrix. |
lambda |
Strength of regularization. It needs to be scaled with |
maxiter_outer |
Maximum number of iterations of the outer loop. Default is 200. |
maxiter_lasso |
Maximum number of iterations of each lasso solver. Default is 200. |
tol |
Tolerance for assessing convergence. Default is 1e-4 and it needs
to be scaled with |
verbose |
Whether to print iterations and differences. Default is FALSE. |
The regularized matrix, where the diagonal should be the same and
zeros should be kept as well. It also returns the lambda
used as an attribute.
(cov <- cov(iris[1:4]))
lambda <- 1 / sqrt(nrow(iris))
(cov_regul <- regul_glasso(cov, lambda))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.