PreEst.glasso {CovTools}R Documentation

Precision Matrix Estimation via Graphical Lasso


Given a sample covariance matrix S, graphical lasso aims at estimating sparse precision matrix X - inverse of covariance. It solves a following optimization problem,

\textrm{max}_X \log\textrm{det}X - <S,X> - λ \|X \|_1 \textrm{ such that } X \succ 0

where λ a regularization parameter, <S,X>=tr(S^T X) , \|X\|_1 = ∑ X_{ij} and X\succ 0 indicates positive definiteness. We provide three modes of computations, 'fixed','confidence', or 'BIC' with respect to λ. Please see the section below for more details.


PreEst.glasso(X, method = list(type = "fixed", param = 1), parallel = FALSE)



an (n\times p) data matrix where each row is an observation.


a list containing following parameters,


one of 'fixed','confidence', or 'BIC'.


either a numeric value or vector of values.


a logical; TRUE for using half the cores available, FALSE otherwise.


a named list containing:


a (p\times p) estimated precision matrix.


a dataframe containing λ values and corresponding BIC scores with type='BIC' method.

regularization parameters

We currently provide three options for solving the problem, 'fixed','confidence', or 'BIC' with respect to λ. When the method type is 'fixed', the parameter should be a single numeric value as a user-defined λ value. Likewise, method type of 'confidence' requires a singule numeric value in (0,1), where the value is set heuristically according to

ρ = \frac{t_{n-2}(γ) \max S_{ii}S_{jj}}{√{n-2+ t_{n-2}^2(γ)}}

for a given confidence level γ \in (0,1) as proposed by Banerjee et al. (2006). Finally, 'BIC' type requires a vector of λ values and opts for a lambda value with the lowest BIC values as proposed by Yuan and Lin (2007).


Banerjee O, Ghaoui LE, d'Aspremont A, Natsoulis G (2006). “Convex optimization techniques for fitting sparse Gaussian graphical models.” In Proceedings of the 23rd international conference on Machine learning, 89–96. ISBN 978-1-59593-383-6.

Yuan M, Lin Y (2007). “Model Selection and Estimation in the Gaussian Graphical Model.” Biometrika, 94(1), 19–35. ISSN 00063444.

Friedman J, Hastie T, Tibshirani R (2008). “Sparse inverse covariance estimation with the graphical lasso.” Biostatistics, 9(3), 432–441. ISSN 1465-4644, 1468-4357.


## generate data from multivariate normal with Identity precision.
pdim = 10
data = matrix(rnorm(100*pdim), ncol=pdim)

## prepare input arguments for diefferent scenarios
lbdvec <- c(0.01,0.1,1,10,100)              # a vector of regularization parameters
list1 <- list(type="fixed",param=1.0)       # single regularization parameter case
list2 <- list(type="confidence",param=0.95) # single confidence level case
list3 <- list(type="BIC",param=lbdvec)      # multiple regularizers with BIC selection

## compute with different scenarios
out1 <- PreEst.glasso(data, method=list1)
out2 <- PreEst.glasso(data, method=list2)
out3 <- PreEst.glasso(data, method=list3)

## visualize
opar <- par(no.readonly=TRUE)
par(mfrow=c(2,2), pty="s")
image(diag(pdim)[,pdim:1], main="Original Precision")
image(out1$C[,pdim:1],     main="glasso::lambda=1.0")
image(out2$C[,pdim:1],     main="glasso::Confidence=0.95")
image(out3$C[,pdim:1],     main="glasso::BIC selection")

[Package CovTools version 0.5.4 Index]