# [GRASS-user] Calculating eigen values and % varianceexplainedafter PCA analysis

Nikos Alexandris nikos.alexandris at felis.uni-freiburg.de
Sun Mar 1 06:36:51 EST 2009

```On Sun, 2009-03-01 at 01:59 -0800, Hamish wrote:
> Hamish wrote:
> > # 'automatic method'
> > imagery60:G6.5svn> i.pca in=spot.ms.1,spot.ms.2,spot.ms.3 out=spot_pca
> >
> > Eigen (vectors) and values:
> > PC1 ( -0.63 -0.65 -0.43 ) 88.07
> > PC2 ( 0.23 0.37 -0.90 ) 11.48
> > PC3 ( 0.75 -0.66 -0.08 ) 0.45
>
> changed to:
> Eigen values, (vectors), and [percent importance]:
> Eigenvalue 1: 1170.12 ( -0.63 -0.65 -0.43 ) [88.07%]
> Eigenvalue 2: 152.49 ( 0.23 0.37 -0.90 ) [11.48%]
> Eigenvalue 3: 6.01 ( 0.75 -0.66 -0.08 ) [0.45%]
>
> Hamish

Congrats after I see that... it works :-p

.

Seriously now: Thank You Hamish!!
Kindest regards, Nikos

P.S. I overdid it with ideas below... :D
---

I am testing... (after the compilation completes). Even before testing I
dould like to drop-in my idea about the output, that is "be more close
to the _standards_ (=e.g. the books present the results)".

* Present first the variance (=eigenvalues) because it's the first
thing you will look at to know "how much variance of the original data
is _expressed_ in each new component.

* The importance, since it refers to the eigenvalue, it's better to
come right after it.

* Column-wise or row-wise? The results can be either presented
column-wise, that is one column for each new component  _or_  row-wise,
as they are currently printed. I think row-wise just looks better :-)

"Some" examples... (only 2 for column-wise and all the rest row-wise...
playing around).

# column-wise examples ##############################################

PC1      PC2      PC3
1170.12  152.49    6.01
[88.07%] [11.48%] [0.47%]
-0.63     0.23     0.75
-0.65     0.37    -0.66
-0.43    -0.90    -0.08

or

#...and perhaps naming each row after
# _original feature_ or
# _original variable_ or
# _original image_ or
# _original dimension_ or
# _original input_ ?

Dimensions      PCA      PC2     PC3
Variance    1170.12   152.49    6.01
Importance  [88.07%] [11.48%] [0.47%]
1st input     -0.63     0.23     0.75
2nd input     -0.65     0.37    -0.66
3rd input     -0.43    -0.90    -0.08

or

Dimensions         PCA      PC2      PC3
Variance       1170.12   152.49     6.01
Importance(%)    88.07    11.48     0.47
1st input        -0.63     0.23     0.75
2nd input        -0.65     0.37    -0.66
3rd input        -0.43    -0.90    -0.08

or

[...]

# row-wise examples ##############################################

Eigenvalues, [importance] and (eigenvectors)
PC1 1170.12 [88.07%] ( -0.63 -0.65 -0.43 )
PC2  152.49 [11.48%] (  0.23  0.37 -0.90 )
PC3    6.01  [0.45%] (  0.75 -0.66 -0.08 )

or

Eigenvalues, importance and (eigenvectors)
PC1 1170.12 88.07% ( -0.63 -0.65 -0.43 )
PC2  152.49 11.48% (  0.23  0.37 -0.90 )
PC3    6.01  0.45% (  0.75 -0.66 -0.08 )

or

Eigenvalues Importance Eigenvectors
PC1 1170.12     88.07%     ( -0.63 -0.65 -0.43 )
PC2  152.49     11.48%     (  0.23  0.37 -0.90 )
PC3    6.01      0.45%     (  0.75 -0.66 -0.08 )

or

Eigenvalues Importance Eigenvectors
PC1  1170.12     88.07%     ( -0.63 -0.65 -0.43 )
PC2   152.49     11.48%     (  0.23  0.37 -0.90 )
PC3     6.01      0.45%     (  0.75 -0.66 -0.08 )

or

Eigenvalues  %      Eigenvectors
PC1  1170.12    88.07   ( -0.63 -0.65 -0.43 )
PC2   152.49    11.48   (  0.23  0.37 -0.90 )
PC3     6.01     0.45   (  0.75 -0.66 -0.08 )

or

Eigenvalues        %            Eigenvectors
PC1      1170.12    88.07   ( -0.63 -0.65 -0.43 )
PC2       152.49    11.48   (  0.23  0.37 -0.90 )
PC3         6.01     0.45   (  0.75 -0.66 -0.08 )

or

Eigenvalues     %   Eigenvectors
PC1  1170.12     88.07   ( -0.63 -0.65 -0.43 )
PC2   152.49     11.48   (  0.23  0.37 -0.90 )
PC3     6.01      0.45   (  0.75 -0.66 -0.08 )

or

Eigenvalues [%] Eigenvectors
PC1  1170.12 [88.07]  ( -0.63 -0.65 -0.43 )
PC2   152.49 [11.48]  (  0.23  0.37 -0.90 )
PC3     6.01  [0.45]  (  0.75 -0.66 -0.08 )

or

Eigenvalues     [%] Eigenvectors
PC1      1170.12 [88.07]  ( -0.63 -0.65 -0.43 )
PC2       152.49 [11.48]  (  0.23  0.37 -0.90 )
PC3         6.01  [0.45]  (  0.75 -0.66 -0.08 )

or

Variance Variance(%) Eigenvectors
PC1  1170.12  88.07     ( -0.63 -0.65 -0.43 )
PC2   152.49  11.48     (  0.23  0.37 -0.90 )
PC3     6.01   0.45     (  0.75 -0.66 -0.08 )

or

Std     %        Eigenvectors
PC1  1170.12  88.07 ( -0.63 -0.65 -0.43 )
PC2   152.49  11.48 (  0.23  0.37 -0.90 )
PC3     6.01   0.45 (  0.75 -0.66 -0.08 )

```