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.
Note: the benchmarks – particularly ADMMsigma
– run significantly faster on my personal machine (MacBook Pro Late 2016). In most cases, the processes take \(\approx\) 25% of the time.
We will be estimating a tri-diagonal precision matrix with dimension \(p = 100\):
library(ADMMsigma)
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)
# benchmark ADMMsigma - default tolerance
microbenchmark(ADMMsigma(S = Sample, lam = 0.1, alpha = 1, tol.abs = 1e-4, tol.rel = 1e-4, trace = "none"))
## Unit: milliseconds
## expr
## ADMMsigma(S = Sample, lam = 0.1, alpha = 1, tol.abs = 1e-04, tol.rel = 1e-04, trace = "none")
## min lq mean median uq max neval
## 353.3034 355.8327 359.1908 357.401 361.0537 378.2791 100
# benchmark ADMMsigma - tolerance 1e-8
microbenchmark(ADMMsigma(S = Sample, lam = 0.1, alpha = 1, tol.abs = 1e-8, tol.rel = 1e-8, trace = "none"))
## Unit: seconds
## expr
## ADMMsigma(S = Sample, lam = 0.1, alpha = 1, tol.abs = 1e-08, tol.rel = 1e-08, trace = "none")
## min lq mean median uq max neval
## 1.261917 1.280508 1.291236 1.287888 1.301755 1.333052 100
lam
and alpha
:# benchmark ADMMsigma CV - default parameter grid
microbenchmark(ADMMsigma(X, trace = "none"), times = 5)
## Unit: seconds
## expr min lq mean median uq
## ADMMsigma(X, trace = "none") 30.38821 30.53333 30.85469 30.5974 31.23629
## max neval
## 31.51823 5
cores = 2
) cross validation:# benchmark ADMMsigma parallel CV
microbenchmark(ADMMsigma(X, cores = 2, trace = "none"), times = 5)
## Unit: seconds
## expr min lq mean
## ADMMsigma(X, cores = 2, trace = "none") 13.34387 13.40334 13.42437
## median uq max neval
## 13.42051 13.44604 13.50807 5
# benchmark ADMMsigma CV - likelihood convergence criteria
microbenchmark(ADMMsigma(X, crit = "loglik", trace = "none"), times = 5)
## Unit: seconds
## expr min lq mean
## ADMMsigma(X, crit = "loglik", trace = "none") 20.38331 21.0669 24.60484
## median uq max neval
## 21.53833 29.96147 30.07418 5
RIDGEsigma
with fine parameter grid:# benchmark RIDGEsigma CV
microbenchmark(RIDGEsigma(X, lam = 10^seq(-8, 8, 0.01), trace = "none"), times = 5)
## Unit: seconds
## expr min
## RIDGEsigma(X, lam = 10^seq(-8, 8, 0.01), trace = "none") 36.30071
## lq mean median uq max neval
## 37.11547 40.06527 40.18395 40.69736 46.02888 5