Dear Sir/Madam,
I am a Ph.D. student at the University of Arizona and in my research, I am
computing eigenvectors for several countries bond yields. I used numerical
fortran and matlab in my computations. To my understanding, matlab uses the
Linear Algebra package (LAPACK) family of routines. I am a bit puzzled about my
results, as I find them to be interesting, as may software developers. I post my
results below.
I used the builtin eig function for matlab, where i pass in a matrix and it
gives me the matrix of eigenvectors and a diagonal matrix containing the
eigenvalues.
Matlab
A =
4.5891 4.2818 3.8384 3.6000 3.3441
4.2818 4.1597 3.8264 3.6378 3.4315
3.8384 3.8264 3.5884 3.4451 3.2885
3.6000 3.6378 3.4451 3.3284 3.1966
3.3441 3.4315 3.2885 3.1966 3.0970
[V,D]=eig(A)
V =
0.1090 0.0979 0.4557 0.7314 0.4857
0.5256 0.3244 0.5994 0.1786 0.4768
0.7991 0.0946 0.3513 0.1815 0.4428
0.2225 0.8053 0.0085 0.3504 0.4233
0.1543 0.4771 0.5563 0.5267 0.4019
D =
0.0012 0 0 0 0
0 0.0015 0 0 0
0 0 0.0136 0 0
0 0 0 0.5493 0
0 0 0 0 18.1970
For fortran, I computed eigenvectors using routines from the IMSL library of
routines (I called the EVCSF routine). The results are shown below
EVAL
1 2 3 4 5
18.20 0.55 0.01 0.00 0.00
EVEC
1 2 3 4 5
1 0.4857 0.7314 0.4558 0.0979 0.1089
2 0.4768 0.1786 0.5994 0.3245 0.5255
3 0.4428 0.1815 0.3513 0.0946 0.7991
4 0.4233 0.3504 0.0085 0.8053 0.2225
5 0.4019 0.5267 0.5563 0.4772 0.1542
The principal components correspond to the eigenvalues with the highest value.
The eigenvalues are the same across the two software packages, and so are the
first, third, fourth, and fifth components. The second component, however, when
computed in matlab is exactly the negative reciprocal, elementwise, of that
obtained from running the EVCSF routine from IMSL numerical fortran.
I also found that these results are systematic, i.e. they are not local to this
data. I computed the eigenvectors for 3 other groups and noticed this same
difference.
Can you please advise?
Thank You!!
Yall have a nice night.
Regards,
Januj
