Library: | nummath |
See also: | pca CPC CPCprop CPCp |
Quantlet: | CPCFGalg | |
Description: | CPCFGalg implements the FG-Algorithm which finds a common orthogonal transformation matrix in order to simultaneously diagonalize several positive definite symmetric matrices. |
Usage: | {B,Phi}=CPCFGalg(A,N) | |
Input: | ||
A | p x p x k array of k positive definite symmetric matrices | |
N | k x 1 vector of weights, usually number of observations in group k | |
Output: | ||
B | p x p matrix, common orthogonal transformation matrix | |
Phi | scalar: Measure of deviation from diagonality. Phi is 1, if complete diagonalizability of the matrices in A was achieved. Phi increases monotonically in deviation from diagonality. |
library("nummath") A11=#(45,10,0,5,0,0)~#(10,45,5,0,0,0)~#(0,5,45,10,0,0) A12=#(5,0,10,45,0,0)~#(0,0,0,0,13.6,4.8)~#(0,0,0,0,4.8,16.4) A21=#(27.5,-12.5,-0.5,-4.5,-2.04,3.72)~#(-12.5,27.5,-4.5,-0.5,2.04,-3.72)~#(-0.5,-4.5,24.5,-9.5,-3.72,-2.04) A22=#(-4.5,-0.5,-9.5,24.5,3.72,2.04)~#(-2.04,2.04,-3.72,3.72,54.76,-4.68)~#(3.72,-3.72,-2.04,2.04,-4.68,51.24) A1=A11~A12 A2=A21~A22 A=reshape(A1~A2, 6|6|2) {B,Phi}=CPCFGalg(A,1|1) B Phi
Contents of B [1,] 0.5 -0.5783 0.5 0.40584 -0.018199 0.023238 [2,] 0.5 0.5783 0.5 -0.40584 0.018199 -0.023238 [3,] -0.5 -0.40577 0.5 -0.57435 -0.0081685 -0.073535 [4,] -0.5 0.40577 0.5 0.57435 0.0081685 0.073535 [5,] -1.7117e-18 -0.041925 4.8648e-18 -0.057801 0.80146 0.59377 [6,] 2.8062e-17 -0.0099156 8.3002e-18 -0.086566 -0.59738 0.79721 Contents of Phi [1,] 1.0176