Type: | Package |
Title: | Constrained L1-Minimization for Inverse (Covariance) Matrix Estimation |
Version: | 0.5.0 |
Date: | 2022-06-13 |
Author: | T. Tony Cai, Weidong Liu and Xi (Rossi) Luo |
Maintainer: | Xi (Rossi) Luo <xi.rossi.luo@gmail.com> |
Depends: | lpSolve |
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>. |
License: | GPL-2 |
NeedsCompilation: | no |
Packaged: | 2022-06-13 15:58:46 UTC; xluo |
Repository: | CRAN |
Date/Publication: | 2022-06-22 09:40:09 UTC |
solve for the inverse matrix
Description
Solve for a series of the inverse covariance matrix estimates at a grid of values for the constraint lambda.
Usage
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)
Arguments
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 |
Details
A constrained \ell_1
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
\min | \Omega |_1 \quad \textrm{subject to: } || \Sigma_n
\Omega - I ||_\infty \le \lambda
where \Sigma_n
is the sample covariance matrix and \Omega
is the inverse we want to estimate.
Value
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. |
Author(s)
T. Tony Cai, Weidong Liu and Xi (Rossi) Luo
Maintainer: Xi (Rossi) Luo xi.rossi.luo@gmail.com
References
Cai, T.T., Liu, W., and Luo, X. (2011).
A constrained \ell_1
minimization approach for sparse precision matrix estimation.
Journal of the American Statistical Association 106(494): 594-607.
Examples
## 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
Description
Internal clime functions
Usage
likelihood(Sigma, Omega)
tracel2(Sigma, Omega)
Arguments
Sigma |
Covariance matrix. |
Omega |
Inverse covariance matrix. |
Details
There are not intended for use by users.
Author(s)
T. Tony Cai, Weidong Liu and Xi (Rossi) Luo
Maintainer: Xi (Rossi) Luo xi.rossi.luo@gmail.com
References
Cai, T.T., Liu, W., and Luo, X. (2011).
A constrained \ell_1
minimization approach for sparse precision matrix estimation.
Journal of the American Statistical Association 106(494): 594-607.
k-fold cross validation for clime object
Description
Perform a k-fold cross validation for selecting lambda
Usage
cv.clime(clime.obj, loss=c("likelihood", "tracel2"), fold=5)
Arguments
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. |
Details
Perform a k-fold cross validation for selecting the tuning parameter
lambda
in clime. Two losses are implemented currently:
\textrm{likelihood: } Tr[\Sigma \Omega] - \log|\Omega| -
p
\textrm{tracel2: } Tr[ diag(\Sigma \Omega - I)^2].
Value
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. |
Author(s)
T. Tony Cai, Weidong Liu and Xi (Rossi) Luo
Maintainer: Xi (Rossi) Luo xi.rossi.luo@gmail.com
References
Cai, T.T., Liu, W., and Luo, X. (2011).
A constrained \ell_1
minimization approach for sparse precision matrix estimation.
Journal of the American Statistical Association 106(494): 594-607.
Examples
## 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 clime object
Description
Print a summary of the clime object.
Usage
## S3 method for class 'clime'
print(x,digits = max(3, getOption("digits") - 3), ... )
Arguments
x |
clime object. |
digits |
significant digits in printout. |
... |
additional print options. |
Details
This call simply outlines the options used for computing a clime object.
Value
The output above is invisiblly returned.
Author(s)
T. Tony Cai, Weidong Liu and Xi (Rossi) Luo
Maintainer: Xi (Rossi) Luo xi.rossi.luo@gmail.com
References
Cai, T.T., Liu, W., and Luo, X. (2011).
A constrained \ell_1
minimization approach for sparse precision matrix estimation.
Journal of the American Statistical Association 106(494): 594-607.
Examples
## trivial example
n <- 50
p <- 5
X <- matrix(rnorm(n*p), nrow=n)
re.clime <- clime(X)
print(re.clime)
print a cross validated clime object
Description
Print a summary of the cv.clime object.
Usage
## S3 method for class 'cv.clime'
print(x,digits = max(3, getOption("digits") - 3), ... )
Arguments
x |
cv.clime object. |
digits |
significant digits in printout. |
... |
additional print options. |
Details
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.
Value
The output above is invisibly returned.
Author(s)
T. Tony Cai, Weidong Liu and Xi (Rossi) Luo
Maintainer: Xi (Rossi) Luo xi.rossi.luo@gmail.com
References
Cai, T.T., Liu, W., and Luo, X. (2011).
A constrained \ell_1
minimization approach for sparse precision matrix estimation.
Journal of the American Statistical Association 106(494): 594-607.
Examples
## 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)