/covKCD

Covariance Estimation for Matrix Data with the Kronecker-Core Decomposition

Primary LanguageR

covKCD

Peter Hoff 2022-08-10

The Kronecker-core decomposition

Let Y_1,\ldots,Y_n be a sample of p_1\times p_2 matrices, and let y_1,\ldots,y_n be their vectorizations. The sample covariance matrix S of y_1,\ldots, y_n is a p\times p positive semidefinite matrix, where p=p_1 \cdot p_2. The Kronecker-core decomposition (K,C) of the covariance matrix S is a matrix factorization of the form

S = (K_2\otimes K_1)^{1/2} C (K_2\otimes K_1)^{1/2},

where

  • K_1 is a p_1\times p_1 matrix representing across-row covariance of the data matrices;
  • K_2 is a p_2\times p_2 matrix representing across-column covariance of the data matrices;
  • C is a core covariance matrix with zero average across-row and across-column covariance.

The covariance matrix K=K_2\otimes K_1 represents the “separable part” of S, whereas C represents the “nonseparable part”. In particular, if S is separable, than C=I_p.

Reference

Hoff, McCormack and Zhang (2022). Core Shrinkage Covariance Estimation for Matrix-variate Data.

Installation

# Development version 
devtools::install_github("pdhoff/covKCD")   

# CRAN-approved version 
install.packages("covKCD") 

Basic usage

p1<-3 ; p2<-4 ; n<-10 

# Random sample of n independent standard normal p1xp2 matrices 
Y<-array(rnorm(n*p1*p2),dim=c(n,p1,p2)) 
dim(Y)
## [1] 10  3  4
# Sample covariance matrix 
S<-covKCD::mcov(Y) 
dim(S) 
## [1] 12 12
# KCD 
KCDS<-covKCD::covKCD(S,p1,p2) 

KCDS$K1 
##             [,1]        [,2]        [,3]
## [1,]  1.33635120 -0.44289281 -0.06881939
## [2,] -0.44289281  0.67144330 -0.02587571
## [3,] -0.06881939 -0.02587571  1.04758540
KCDS$K2
##             [,1]       [,2]        [,3]        [,4]
## [1,]  0.94256591  0.1405612 -0.23992050  0.01091884
## [2,]  0.14056122  0.9621321 -0.25617191 -0.01655000
## [3,] -0.23992050 -0.2561719  1.15019722  0.08804809
## [4,]  0.01091884 -0.0165500  0.08804809  0.70790240
# Check decomposition 
K1h<-covKCD::msqrt(KCDS$K1) 
K2h<-covKCD::msqrt(KCDS$K2) 

range( kronecker(K2h,K1h) %*% KCDS$C %*% kronecker(K2h,K1h) - S )
## [1] -1.887379e-15  1.370432e-15

Additional examples