Title: | Constrained L1-Minimization for Inverse (Covariance) Matrix Estimation |
---|---|
Description: | A robust constrained L1 minimization method for estimating a large sparse inverse covariance matrix (aka precision matrix), and recovering its support for building graphical models. The computation uses linear programming. The method was published in TT Cai, W Liu, X Luo (2011) <doi:10.1198/jasa.2011.tm10155>. |
Authors: | T. Tony Cai, Weidong Liu and Xi (Rossi) Luo |
Maintainer: | Xi (Rossi) Luo <[email protected]> |
License: | GPL-2 |
Version: | 0.5.0 |
Built: | 2025-01-04 03:09:02 UTC |
Source: | https://github.com/rluo/clime |
Solve for a series of the inverse covariance matrix estimates at a grid of values for the constraint lambda.
clime(x, lambda=NULL, nlambda=ifelse(is.null(lambda),100,length(lambda)), lambda.max=0.8, lambda.min=ifelse(nrow(x)>ncol(x), 1e-4, 1e-2), sigma=FALSE, perturb=TRUE, standardize=TRUE, logspaced=TRUE, linsolver=c("primaldual", "simplex"), pdtol=1e-3, pdmaxiter=50)
clime(x, lambda=NULL, nlambda=ifelse(is.null(lambda),100,length(lambda)), lambda.max=0.8, lambda.min=ifelse(nrow(x)>ncol(x), 1e-4, 1e-2), sigma=FALSE, perturb=TRUE, standardize=TRUE, logspaced=TRUE, linsolver=c("primaldual", "simplex"), pdtol=1e-3, pdmaxiter=50)
x |
Input matrix of size n (observations) times p (variables).
Each column is a variable of length n. Alternatively, the sample
covariance matrix may be set here with the next option |
lambda |
Grid of non-negative values for the constraint
parameter lambda. If missing, |
standardize |
Whether the variables will be standardized to have mean zero and unit standard deviation. Default TRUE. |
nlambda |
Number of values for program generated |
lambda.max |
Maximum value of program generated |
lambda.min |
Minimum value of program generated |
sigma |
Whether |
perturb |
Whether a perturbed |
logspaced |
Whether program generated lambda should be log-spaced or linear spaced. Default TRUE. |
linsolver |
Whether |
pdtol |
Tolerance for the duality gap, ignored if |
pdmaxiter |
Maximum number of iterations for |
A constrained
minimization approach for sparse precision matrix estimation (details
in references) is implemented here using linear programming (revised
simplex or primal-dual interior point method). It solves a sequence of
lambda
values on the following objective function
where is the sample covariance matrix and
is the inverse we want to estimate.
An object with S3 class "clime"
. You can also use it as a
regular R list with the following fields:
Omega |
List of estimated inverse covariance matrix for a grid of
values for |
lambda |
Actual sequence of |
perturb |
Actual perturbation used in the program. |
standardize |
Whether standardization is applied to the columns
of |
x |
Actual |
lpfun |
Linear programming solver used. |
T. Tony Cai, Weidong Liu and Xi (Rossi) Luo
Maintainer: Xi (Rossi) Luo [email protected]
Cai, T.T., Liu, W., and Luo, X. (2011).
A constrained
minimization approach for sparse precision matrix estimation.
Journal of the American Statistical Association 106(494): 594-607.
## trivial example n <- 50 p <- 5 X <- matrix(rnorm(n*p), nrow=n) re.clime <- clime(X) ## tridiagonal matrix example bandMat <- function(p, k) { cM <- matrix(rep(1:p, each=p), nrow=p, ncol=p) return((abs(t(cM)-cM)<=k)*1) } ## tridiagonal Omega with diagonal 1 and off-diagonal 0.5 Omega <- bandMat(p, 1)*0.5 diag(Omega) <- 1 Sigma <- solve(Omega) X <- matrix(rnorm(n*p), nrow=n)%*%chol(Sigma) re.clime <- clime(X, standardize=FALSE, linsolver="simplex") re.cv <- cv.clime(re.clime) re.clime.opt <- clime(X, standardize=FALSE, re.cv$lambdaopt) ## Compare Frobenius norm loss ## clime estimator sqrt( sum( (Omega-re.clime.opt$Omegalist[[1]])^2 ) ) ## Not run: 0.3438533 ## Sample covariance matrix inversed sqrt( sum( ( Omega-solve(cov(X)*(1-1/n)) )^2 ) ) ## Not run: 0.874041 sqrt( sum( ( Omega-solve(cov(X)) )^2 ) ) ## Not run: 0.8224296
## trivial example n <- 50 p <- 5 X <- matrix(rnorm(n*p), nrow=n) re.clime <- clime(X) ## tridiagonal matrix example bandMat <- function(p, k) { cM <- matrix(rep(1:p, each=p), nrow=p, ncol=p) return((abs(t(cM)-cM)<=k)*1) } ## tridiagonal Omega with diagonal 1 and off-diagonal 0.5 Omega <- bandMat(p, 1)*0.5 diag(Omega) <- 1 Sigma <- solve(Omega) X <- matrix(rnorm(n*p), nrow=n)%*%chol(Sigma) re.clime <- clime(X, standardize=FALSE, linsolver="simplex") re.cv <- cv.clime(re.clime) re.clime.opt <- clime(X, standardize=FALSE, re.cv$lambdaopt) ## Compare Frobenius norm loss ## clime estimator sqrt( sum( (Omega-re.clime.opt$Omegalist[[1]])^2 ) ) ## Not run: 0.3438533 ## Sample covariance matrix inversed sqrt( sum( ( Omega-solve(cov(X)*(1-1/n)) )^2 ) ) ## Not run: 0.874041 sqrt( sum( ( Omega-solve(cov(X)) )^2 ) ) ## Not run: 0.8224296
Internal clime functions
likelihood(Sigma, Omega) tracel2(Sigma, Omega)
likelihood(Sigma, Omega) tracel2(Sigma, Omega)
Sigma |
Covariance matrix. |
Omega |
Inverse covariance matrix. |
There are not intended for use by users.
T. Tony Cai, Weidong Liu and Xi (Rossi) Luo
Maintainer: Xi (Rossi) Luo [email protected]
Cai, T.T., Liu, W., and Luo, X. (2011).
A constrained
minimization approach for sparse precision matrix estimation.
Journal of the American Statistical Association 106(494): 594-607.
Perform a k-fold cross validation for selecting lambda
cv.clime(clime.obj, loss=c("likelihood", "tracel2"), fold=5)
cv.clime(clime.obj, loss=c("likelihood", "tracel2"), fold=5)
clime.obj |
clime object output from |
loss |
loss to be used in cross validation. Currently, two losses are available: "likelihood" and "tracel2". Default "likelihood". |
fold |
number of folds used in cross validation. Default 5. |
Perform a k-fold cross validation for selecting the tuning parameter
lambda
in clime. Two losses are implemented currently:
An object with S3 class "cv.clime"
. You can use it as a
regular R list with the following fields:
lambdaopt |
the lambda selected by cross validation to minimize the loss over
the grid values of |
loss |
the name of loss used in cross validation. |
lambda |
sequence of |
loss.mean |
average k-fold loss values for each grid value |
loss.mean |
standard deviation of k-fold loss values for each grid value |
lpfun |
Linear programming solver used. |
T. Tony Cai, Weidong Liu and Xi (Rossi) Luo
Maintainer: Xi (Rossi) Luo [email protected]
Cai, T.T., Liu, W., and Luo, X. (2011).
A constrained
minimization approach for sparse precision matrix estimation.
Journal of the American Statistical Association 106(494): 594-607.
## trivial example n <- 50 p <- 5 X <- matrix(rnorm(n*p), nrow=n) re.clime <- clime(X) re.cv <- cv.clime(re.clime) re.clime.opt <- clime(X, re.cv$lambdaopt)
## trivial example n <- 50 p <- 5 X <- matrix(rnorm(n*p), nrow=n) re.clime <- clime(X) re.cv <- cv.clime(re.clime) re.clime.opt <- clime(X, re.cv$lambdaopt)
Print a summary of the clime object.
## S3 method for class 'clime' print(x,digits = max(3, getOption("digits") - 3), ... )
## S3 method for class 'clime' print(x,digits = max(3, getOption("digits") - 3), ... )
x |
clime object. |
digits |
significant digits in printout. |
... |
additional print options. |
This call simply outlines the options used for computing a clime object.
The output above is invisiblly returned.
T. Tony Cai, Weidong Liu and Xi (Rossi) Luo
Maintainer: Xi (Rossi) Luo [email protected]
Cai, T.T., Liu, W., and Luo, X. (2011).
A constrained
minimization approach for sparse precision matrix estimation.
Journal of the American Statistical Association 106(494): 594-607.
## trivial example n <- 50 p <- 5 X <- matrix(rnorm(n*p), nrow=n) re.clime <- clime(X) print(re.clime)
## trivial example n <- 50 p <- 5 X <- matrix(rnorm(n*p), nrow=n) re.clime <- clime(X) print(re.clime)
Print a summary of the cv.clime object.
## S3 method for class 'cv.clime' print(x,digits = max(3, getOption("digits") - 3), ... )
## S3 method for class 'cv.clime' print(x,digits = max(3, getOption("digits") - 3), ... )
x |
cv.clime object. |
digits |
significant digits in printout. |
... |
additional print options. |
This call outputs first a three column matrix with lambda
, mean
and sd
for the cross validation loss values. The actual loss
used and the optimal lambda
value picked by cv are printed.
The output above is invisibly returned.
T. Tony Cai, Weidong Liu and Xi (Rossi) Luo
Maintainer: Xi (Rossi) Luo [email protected]
Cai, T.T., Liu, W., and Luo, X. (2011).
A constrained
minimization approach for sparse precision matrix estimation.
Journal of the American Statistical Association 106(494): 594-607.
## trivial example n <- 50 p <- 5 X <- matrix(rnorm(n*p), nrow=n) re.clime <- clime(X) re.cv <- cv.clime(re.clime) print(re.cv)
## trivial example n <- 50 p <- 5 X <- matrix(rnorm(n*p), nrow=n) re.clime <- clime(X) re.cv <- cv.clime(re.clime) print(re.cv)