gemmr.generative_model._assemble_Sigmaxy_cca

gemmr.generative_model._assemble_Sigmaxy_cca(Sigmaxx, Sigmayy, U_, V_, m, true_corrs)

Generates the between-set covariance matrix for CCA.

To solve CCA consider the matrix

\[K = \Sigma_{XX}^{-1/2} \Sigma_{XY} \Sigma_{YY}^{-1/2}\]

and perform a singular value composition

\[K = U \mathrm{diag}( \vec{\sigma}) V^T\]

where \(U\) and \(V\) are unitary. The vector \(\vec{\sigma}\) contains the canonical correlations and the weights are given by

\[ \begin{align}\begin{aligned}W_X = \Sigma_{XX}^{-1/2} U\\W_Y = \Sigma_{YY}^{-1/2} V\end{aligned}\end{align} \]

Conversely, the covariance matrix associated with given canonical correlations \(\vec{\sigma}\) and weights \(W_X\) and \(W_Y\) is given by

\[ \begin{align}\begin{aligned}\Sigma_{XY} = \Sigma_{XX}^{1/2} K \Sigma_{YY}^{1/2}\\ = \Sigma_{XX}^{1/2} U \mathrm{diag}( \vec{\sigma}) V^T \Sigma_{YY}^{1/2}\\ = \Sigma_{XX} W_X \mathrm{diag}( \vec{\sigma}) W_Y^T \Sigma_{YY}\end{aligned}\end{align} \]

with the constraints that \(U=\Sigma_{XX}^{-1/2} W_X\) and \(V=\Sigma_{YY}^{-1/2} W_Y\) are unitary. If the data are white, i.e. if \(\Sigma_{XX}=\Sigma_{YY}=\mathrm{diag}(1, ..., 1)\) the constraints are satisfied trivially. Also, if only one between-set mode is sought, i.e. if \(\vec{\sigma}\) contains a single element and the weights \(W_X\) and \(W_Y\) have a single column each the constrained is satisfied. The general case is not implemented at the moment.

With the generated \(\Sigma_{XY}\) the joint covariance matrix \(\Sigma\) can be assembled. To test its positive-definiteness, this function also returns the minimal eigenvalue of a Schur complement of \(\Sigma\) (which is > 0 if and only if \(\Sigma\) is positive definite).

Parameters:
  • Sigmaxx (np.ndarray (px, px)) – within-set covariance matrix for X
  • Sigmayy (np.ndarray (py, py)) – within-set covariance matrix for Y
  • U (np.ndarray (px, m)) – weight vectors for between-set association modes in X
  • V (np.ndarray (py, m)) – weight vectors for between-set association modes in Y
  • m (int) – number of between-set association modes
  • true_corrs (np.ndarray (m,)) – assumed correlations for the between-set association modes
Returns:

  • Sigmaxy (np.ndarray (px, py)) – between-set covariance matrix
  • Sigmaxy_svals (np.ndarray (m,)) – singular values of Sigmaxy, these are the true canonical correlations and identical to true_corrs
  • U_ (np.ndarray (px, m)) – weight vectors for between-set association modes in X
  • V_ (np.ndarray (py, m)) – weight vectors for between-set association modes in Y
  • min_eval (float) – smallest eigenvalue of the Schur complement of either Sigmaxx or Sigmayy (whichever has a larger dimension) of the joint covariance matrix \(\Sigma\). \(\Sigma\) is positive definite if and only if min_eval is > 0.
  • true_corrs (np.ndarray (m,)) – assumed correlations for the between-set association modes