Title: | Graphical Continuous Lyapunov Models |
---|---|
Description: | Estimation of covariance matrices as solutions of continuous time Lyapunov equations. Sparse coefficient matrix and diagonal noise are estimated with a proximal gradient method for an l1-penalized loss minimization problem. Varando G, Hansen NR (2020) <arXiv:2005.10483>. |
Authors: | Gherardo Varando [aut, cre, cph] , Niels Richard Hansen [aut] |
Maintainer: | Gherardo Varando <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.0.1 |
Built: | 2024-11-03 06:43:38 UTC |
Source: | CRAN |
Generate a naive stable matrix
B0(p)
B0(p)
p |
dimension of the matrix |
a stable matrix with off-diagonal entries equal to 1 and
diagonal entries equal to -p
clyap
solve the continuous-time Lyapunov equations
Using the Bartels-Stewart algorithm with Hessenberg–Schur decomposition. Optionally the Hessenberg-Schur decomposition can be returned.
clyap(B, C, Q = NULL, all = FALSE)
clyap(B, C, Q = NULL, all = FALSE)
B |
Square matrix |
C |
Square matrix |
Q |
Square matrix, the orthogonal matrix used to transform the original equation |
all |
logical |
If the matrix Q
is set then the matrix B
is assumed to be in upper quasi-triangular form
(Hessenberg-Schur canonical form),
as required by LAPACK subroutine DTRSYL
and Q
is
the orthogonal matrix associated with the Hessenberg-Schur form
of B
.
Usually the matrix Q
and the appropriate form of B
are obtained by a first call to clyap(B, C, all = TRUE)
clyap
uses lapack subroutines:
DGEES
DTRSYL
DGEMM
The solution matrix X
if all = FALSE
. If
all = TRUE
a list with components X
, B
and Q
. Where B
and Q
are the
Hessenberg-Schur form of the original matrix B
and the orthogonal matrix that performed the transformation.
B <- matrix(data = rnorm(9), nrow = 3) ## make B negative diagonally dominant, thus stable: diag(B) <- - 3 * max(B) C <- diag(runif(3)) X <- clyap(B, C) ## check X is a solution: max(abs(B %*% X + X %*% t(B) + C))
B <- matrix(data = rnorm(9), nrow = 3) ## make B negative diagonally dominant, thus stable: diag(B) <- - 3 * max(B) C <- diag(runif(3)) X <- clyap(B, C) ## check X is a solution: max(abs(B %*% X + X %*% t(B) + C))
Estimates a sparse continuous time Lyapunov parametrization of a covariance matrix using a lasso (L1) penalty.
gclm( Sigma, B = -0.5 * diag(ncol(Sigma)), C = rep(1, ncol(Sigma)), C0 = rep(1, ncol(Sigma)), loss = "loglik", eps = 0.01, alpha = 0.5, maxIter = 100, lambda = 0, lambdac = 0, job = 0 ) gclm.path( Sigma, lambdas = NULL, B = -0.5 * diag(ncol(Sigma)), C = rep(1, ncol(Sigma)), ... )
gclm( Sigma, B = -0.5 * diag(ncol(Sigma)), C = rep(1, ncol(Sigma)), C0 = rep(1, ncol(Sigma)), loss = "loglik", eps = 0.01, alpha = 0.5, maxIter = 100, lambda = 0, lambdac = 0, job = 0 ) gclm.path( Sigma, lambdas = NULL, B = -0.5 * diag(ncol(Sigma)), C = rep(1, ncol(Sigma)), ... )
Sigma |
covariance matrix |
B |
initial B matrix |
C |
diagonal of initial C matrix |
C0 |
diagonal of penalization matrix |
loss |
one of "loglik" (default) or "frobenius" |
eps |
convergence threshold |
alpha |
parameter line search |
maxIter |
maximum number of iterations |
lambda |
penalization coefficient for B |
lambdac |
penalization coefficient for C |
job |
integer 0,1,10 or 11 |
lambdas |
sequence of lambda |
... |
additional arguments passed to |
gclm
performs proximal gradient descent for the optimization problem
subject to stable and
diagonal, where
is the l1 norm
of the off-diagonal element of
.
gclm.path
simply calls iteratively gclm
with different lambda
values. Warm start is used, that
is in the i-th call to gclm
the B
and C
matrices are initialized as the one obtained in the (i-1)th
call.
for gclm
: a list with the result of the optimization
for gclm.path
: a list of the same length of
lambdas
with the results of the optimization for
the different lambda
values
x <- matrix(rnorm(50*20),ncol=20) S <- cov(x) ## l1 penalized log-likelihood res <- gclm(S, eps = 0, lambda = 0.1, lambdac = 0.01) ## l1 penalized log-likelihood with fixed C res <- gclm(S, eps = 0, lambda = 0.1, lambdac = -1) ## l1 penalized frobenius loss res <- gclm(S, eps = 0, lambda = 0.1, loss = "frobenius")
x <- matrix(rnorm(50*20),ncol=20) S <- cov(x) ## l1 penalized log-likelihood res <- gclm(S, eps = 0, lambda = 0.1, lambdac = 0.01) ## l1 penalized log-likelihood with fixed C res <- gclm(S, eps = 0, lambda = 0.1, lambdac = -1) ## l1 penalized frobenius loss res <- gclm(S, eps = 0, lambda = 0.1, loss = "frobenius")
Recover the only lower triangular stable matrix B such that
Sigma
()
is the solution of the associated continuous Lyapunov equation:
gclm.lowertri(Sigma, P = solve(Sigma), C = diag(nrow = nrow(Sigma)))
gclm.lowertri(Sigma, P = solve(Sigma), C = diag(nrow = nrow(Sigma)))
Sigma |
covariance matrix |
P |
the inverse of the covariance matrix |
C |
symmetric positive definite matrix |
A stable lower triangular matrix