3
$\begingroup$

I am using glasso function from glasso package, as follow:

obj <- glasso(var(X), rho = 0.09, zero = info, approx=TRUE)

Regardless of rho value, all of entries in obj$w, estimated covariance matrix, are zero. Do you have any idea why this happens?

For your information, the dimension of var(X) is 1990 x 1990 and the number of rows in info is 1959841.

EDIT: You can download X and info variables as RData file from this link: https://www.dropbox.com/s/t9s4iw6ulbys72o/varX.RData?dl=0

$\endgroup$
6
  • $\begingroup$ I don't know anything about this, but a quick perusal of cran.r-project.org/web/packages/glasso/glasso.pdf , shows that your 'info' is being used to specify entries in the estimated (inverse) covariance matrix which are constrained to be zero. Are you constraining all entries to be zero, or at least enough of them that all zeros is the only solution it can find? What are the contents of 'info'? $\endgroup$ Commented Apr 23, 2016 at 16:01
  • $\begingroup$ @MarkL.Stone Indeed I force the algorithm to make most of the entries zero and only about 5300 entries are non-zero which I would like to estimate. $\endgroup$ Commented Apr 23, 2016 at 16:05
  • $\begingroup$ First of all, per the documentation, each element (k,j) is constrained to be zero if (j,k) is constrained to be zero. Does that still leave you with 5300 elements not constrained to be zero? Second of all, however many unconstrained elements you think that leaves you, I presume the estimated matrix must be positive semi-definite (PSD). The elements constrained to be zero can indirectly constrain other elements of the matrix due to the PSD constraint. Are you constraining any diagonal elements to be zero? I think you will find the specification of elements constrained to be zero to be key. $\endgroup$ Commented Apr 23, 2016 at 16:18
  • $\begingroup$ @MarkL.Stone Thanks. The weird thing is that even by running glasso(var(X), rho = 0.01, zero = info[-c(1000:1950000),], approx=TRUE), the estimated cov matrix is still zero!! $\endgroup$ Commented Apr 23, 2016 at 16:37
  • $\begingroup$ What happens when you set zero = NULL (i.e., not specify zero)? Sorry, I don't know what zeros you have specified when you do zero = info[-c(1000:1950000),]. Are you leaving out your first 999 constraints (whatever they are)? $\endgroup$ Commented Apr 23, 2016 at 16:44

2 Answers 2

1
$\begingroup$

I was having the same problem and discovered it was related to the parameter approx=TRUE, which lets glasso use an approximation method used to speed up the inversion of the covariance matrix, so the problem may be related to the original covariance matrix s not fulfilling the assumptions used for this method.

In my case my matrix wasn't that big (800x800), so I was able to fix the problem just by setting the approx parameter to FALSE and being a little patient, but I know this may not be feasible for larger matrices, so I hope someone could share a better solution for this problem.

$\endgroup$
0
$\begingroup$

I did some experimentation with the glasso function and I find that it does not return the covariance matrix w, and the inverse covariance matrix wi lacks the diagonal terms and is not symmetric.

Setting up ...

library(glasso)

n <- 20
k <- 3
x <- matrix(rnorm(n*k),ncol=k)

Since n > k, the covariance matrix can be inverted directly.

> var(x)
            [,1]        [,2]       [,3]
[1,]  1.37818760 -0.03676559 -0.0446064
[2,] -0.03676559  1.15692561 -0.4592093
[3,] -0.04460640 -0.45920931  1.1981595
> solve(var(x))
           [,1]       [,2]       [,3]
[1,] 0.72803016 0.03997524 0.04242491
[2,] 0.03997524 1.02163778 0.39304343
[3,] 0.04242491 0.39304343 0.98683155

With approx=FALSE the glasso function uses the lasso method and gets the right answer.

> glasso(var(x),rho=0,approx=FALSE)[c('w','wi')]
$w
            [,1]        [,2]        [,3]
[1,]  1.37818760 -0.03676557 -0.04460639
[2,] -0.03676557  1.15692561 -0.45920931
[3,] -0.04460639 -0.45920931  1.19815952

$wi
           [,1]       [,2]       [,3]
[1,] 0.72803010 0.03997522 0.04242489
[2,] 0.03997386 1.02163778 0.39304343
[3,] 0.04242438 0.39304343 0.98683155

Setting approx=TRUE causes the function to use the Meinshausen-Buhlmann method, and that seems to be poorly implemented.

> glasso(var(x),rho=0,approx=TRUE)[c('w','wi')]
$w
     [,1] [,2] [,3]
[1,]    0    0    0
[2,]    0    0    0
[3,]    0    0    0

$wi
            [,1]        [,2]        [,3]
[1,]  0.00000000 -0.03912856 -0.04299102
[2,] -0.05490688  0.00000000 -0.39828827
[3,] -0.05827283 -0.38471896  0.00000000

Now that I look at it, the wi returned by setting approx=TRUE looks like the covariance, not inverse covariance, matrix. This is a serious error in glasso function. Or maybe it's an error in the documentation. Either way, it's serious.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.