regul_glasso: Regularization with the graphical lasso

View source: R/glasso.R

regul_glassoR Documentation

Regularization with the graphical lasso

Description

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.

Usage

regul_glasso(
  mat,
  lambda,
  maxiter_outer = 200,
  maxiter_lasso = 200,
  tol = 1e-04,
  verbose = FALSE
)

Arguments

mat

A square symmetric matrix.

lambda

Strength of regularization. It needs to be scaled with mat. It should also be the maximum difference between the two matrices.

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 mat.

verbose

Whether to print iterations and differences. Default is FALSE.

Value

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.

Examples

(cov <- cov(iris[1:4]))
lambda <- 1 / sqrt(nrow(iris))
(cov_regul <- regul_glasso(cov, lambda))

privefl/bigutilsr documentation built on Jan. 27, 2024, 5:33 a.m.