This is a short effort to give users an idea of how long the functions take to process. The benchmarks were performed using the default R install on Travis CI.
We will be estimating a tri-diagonal precision matrix with dimension \(p = 100\):
library(GLASSOO)
library(microbenchmark)
# generate data from tri-diagonal (sparse) matrix
# compute covariance matrix (can confirm inverse is tri-diagonal)
S = matrix(0, nrow = 100, ncol = 100)
for (i in 1:100){
for (j in 1:100){
S[i, j] = 0.7^(abs(i - j))
}
}
# generate 1000 x 100 matrix with rows drawn from iid N_p(0, S)
set.seed(123)
Z = matrix(rnorm(1000*100), nrow = 1000, ncol = 100)
out = eigen(S, symmetric = TRUE)
S.sqrt = out$vectors %*% diag(out$values^0.5) %*% t(out$vectors)
X = Z %*% S.sqrt
# calculate sample covariance matrix
sample = (nrow(X) - 1)/nrow(X)*cov(X)
## Unit: milliseconds
## expr min lq mean
## GLASSO(S = sample, lam = 0.1, trace = "none") 169.3704 173.3424 175.9905
## median uq max neval
## 174.9908 177.0388 199.4217 100
lam
:# benchmark CVglasso CV - default parameter grid
microbenchmark(GLASSO(X, trace = "none"), times = 5)
## Unit: seconds
## expr min lq mean median uq
## GLASSO(X, trace = "none") 9.408677 9.451392 9.946536 10.09357 10.24701
## max neval
## 10.53203 5
cores = 2
) cross validation:## Unit: seconds
## expr min lq mean median
## GLASSO(X, cores = 2, trace = "none") 7.057724 7.063606 7.374455 7.322304
## uq max neval
## 7.337788 8.090854 5