clime {clime} | R Documentation |
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