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

8 messages Options
Embed this post
Permalink
hamish-2

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

Reply Threaded More More options
Print post
Permalink

Nikos wrote:
> It should be the case with i.pca as well since eigen_VALUES_ (=represent
> the variances of the original dimensions that are "kept" in each
> component) are important for the interpretation of what exactly are each
> of the components. But, i.pca just does not report the eigen_VALUES_.
>
> At some point some C-expert needs to have a look in the code (i.pca) and
> correct the "bug" which does not let the eigen_VALUES_ from being
> printed.

done in devbr6 (6.5svn) please test, I'm not a multivariate stats guru
and may have done something dumb so didn't port to other branches yet.

I changed the i.pca output to be like:

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

As it was previously sent to stderr via G_message() I don't feel bad about
breaking output text compatibility. I wanted to add "%" to the values but
due to the sprintf()+strcat() method in the code that was a pain, so I
didn't.


> >  If this is the case then both methods still differ significantly. Is
> > this possible, and which should I use.
>
> Please have a look at my comments/questions in link [2].
> i.pca follows the "SVD" method. You performed the non-standartised PCA
> using the covariance matrix. Note that you can use also the
> standartised method by using the correlation matrix.

does the r.mapcalc command at the end of the m.eigensystem help page*
do that conversion, or ...? ie how can we test these against each other?
how to do the standardized method?

[*] (is "\-" there a typo or some old mapcalc syntax?)

also ISTR somebody (Dylan?) doing a comparison with the R-stats interface.


It would be nice to run tests using the Spearfish imagery dataset. After
my own tests I noticed it matched what was used in the m.eigensystem help
page.


my results follow.

Hamish


----------------------------
#Spearfish imagery sample dataset
g.region rast=spot.ms.1


# 'by-hand-method'
G65> echo "3" > test_m.eigensystem    # number of input maps
G65> r.covar map=spot.ms.1,spot.ms.2,spot.ms.3 >> test_m.eigensystem

G65> cat test_m.eigensystem
3
462.876649 480.411218 281.758307
480.411218 513.015646 278.914813
281.758307 278.914813 336.326645


G65> m.eigensystem < test_m.eigensystem
-----
C The output is N sets of values. One E line and N V W lines
C
C  E   real  imaginary   percent-importance
C  V   real  imaginary
C  N   real  imaginary
C  W   real  imaginary
C      ...
C
C where E is the eigen value (and it relative importance)
C and   V are the eigenvector for this eigenvalue.
C       N are the normalized eigenvector for this eigenvalue.
C       W are the N vector multiplied by the square root of the
C         magnitude of the eigen value (E).
-----

E      1159.7452017844         0.0000000000    88.38
V         0.6910021591         0.0000000000
V         0.7205280412         0.0000000000
V         0.4805108400         0.0000000000
N         0.6236808478         0.0000000000
N         0.6503301526         0.0000000000
N         0.4336967751         0.0000000000
W        21.2394712045         0.0000000000
W        22.1470141296         0.0000000000
W        14.7695575384         0.0000000000

E         5.9705414972         0.0000000000     0.45
V         0.7119385973         0.0000000000
V        -0.6358200627         0.0000000000
V        -0.0703936743         0.0000000000
N         0.7438340890         0.0000000000
N        -0.6643053754         0.0000000000
N        -0.0735473745         0.0000000000
W         1.8175356507         0.0000000000
W        -1.6232096923         0.0000000000
W        -0.1797107407         0.0000000000

E       146.5031967184         0.0000000000    11.16
V         0.2265837636         0.0000000000
V         0.3474697082         0.0000000000
V        -0.8468727535         0.0000000000
N         0.2402770238         0.0000000000
N         0.3684685345         0.0000000000
N        -0.8980522763         0.0000000000
W         2.9082771721         0.0000000000
W         4.4598880523         0.0000000000
W       -10.8698904856         0.0000000000


# 'all-in-one method' using r.covar+m.eigensystem:
G65> (echo 3; r.covar spot.ms.1,spot.ms.2,spot.ms.3 ) | m.eigensystem

Then, using the W vector, new maps are created:
r.mapcalc 'pc.1 = 21.2395*map.1 + 22.1470*map.2 + 14.7696*map.3'
r.mapcalc 'pc.2 =  2.9083*map.1 +  4.4599*map.2  - 10.8699*map.3'
r.mapcalc 'pc.3 =  1.8175*map.1  -  1.6232*map.2 \-  0.1797*map.3'

(is "\-" above a typo or some old mapcalc syntax?)

which look highly similar (but not identical) to i.pca output maps.
(after 'r.colors color=grey')



# '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



     

_______________________________________________
grass-stats mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-stats
hamish-2

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

Reply Threaded More More options
Print post
Permalink

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%]

comments welcome.


Hamish



     

_______________________________________________
grass-stats mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-stats
Nikos Alexandris

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

Reply Threaded More More options
Print post
Permalink
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%]
>
> comments welcome.
> 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.

   * Present the loadings (eigenvectors) for each new component.

   * 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 )


_______________________________________________
grass-stats mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-stats
Nikos Alexandris

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

Reply Threaded More More options
Print post
Permalink
In reply to this post by hamish-2

Nikos:
> [...] i.pca just does not report the eigen_VALUES_. At some point some
> C-expert needs to have a look in the code (i.pca) and correct the
> "bug" which does not let the eigen_VALUES_ from being printed.


Hamish:
> done in devbr6 (6.5svn) please test, I'm not a multivariate stats guru
> and may have done something dumb so didn't port to other branches yet.


First test:

[...]
Following modules are missing the 'description.html' file in src code:
----------------------------------------------------------------------
GRASS GIS compilation log
-------------------------
Started compilation: Sun Mar  1 11:41:04 CET 2009
--
Errors in:
/usr/local/src/grass6_devel/imagery/i.pca
--
In case of errors please change into the directory with error and run 'make'.
If you get multiple errors, you need to deal with them in the order they
appear in the error log. If you get an error building a library, you will
also get errors from anything which uses the library.
--
Finished compilation: Sun Mar  1 11:46:34 CET 2009
make: *** [default] Error 1
nik@vertical:/usr/local/src/grass6_devel$ cd imagery/i.pca/
nik@vertical:/usr/local/src/grass6_devel/imagery/i.pca$ make
gcc -I/usr/local/src/grass6_devel/dist.x86_64-unknown-linux-gnu/include  -g -Wall       -DPACKAGE=\""grassmods"\"  -I/usr/local/src/grass6_devel/dist.x86_64-unknown-linux-gnu/include -o OBJ.x86_64-unknown-linux-gnu/support.o -c support.c
support.c: In function ‘write_history’:
support.c:43: error: expected expression before ‘<<’ token
support.c:46: error: expected expression before ‘==’ token
support.c:49: error: expected expression before ‘>>’ token
support.c:67: warning: format not a string literal and no format arguments
make: *** [OBJ.x86_64-unknown-linux-gnu/support.o] Error 1


# Am I doing something wrong?

_______________________________________________
grass-stats mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-stats
Nikos Alexandris

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

Reply Threaded More More options
Print post
Permalink
On Sun, 2009-03-01 at 12:46 +0100, Nikos Alexandris wrote:

> Nikos:
> > [...] i.pca just does not report the eigen_VALUES_. At some point some
> > C-expert needs to have a look in the code (i.pca) and correct the
> > "bug" which does not let the eigen_VALUES_ from being printed.
>
>
> Hamish:
> > done in devbr6 (6.5svn) please test, I'm not a multivariate stats guru
> > and may have done something dumb so didn't port to other branches yet.
>
>
> First test:
[...]
> Errors in:
> /usr/local/src/grass6_devel/imagery/i.pca
[...]

> Finished compilation: Sun Mar  1 11:46:34 CET 2009
> make: *** [default] Error 1
> nik@vertical:/usr/local/src/grass6_devel$ cd imagery/i.pca/
> nik@vertical:/usr/local/src/grass6_devel/imagery/i.pca$ make
> gcc -I/usr/local/src/grass6_devel/dist.x86_64-unknown-linux-gnu/include  -g -Wall       -DPACKAGE=\""grassmods"\"  -I/usr/local/src/grass6_devel/dist.x86_64-unknown-linux-gnu/include -o OBJ.x86_64-unknown-linux-gnu/support.o -c support.c
> support.c: In function ‘write_history’:
> support.c:43: error: expected expression before ‘<<’ token
> support.c:46: error: expected expression before ‘==’ token
> support.c:49: error: expected expression before ‘>>’ token
> support.c:67: warning: format not a string literal and no format arguments
> make: *** [OBJ.x86_64-unknown-linux-gnu/support.o] Error 1


OK, I removed the lines below, compiled again and now it works.
Perfect!!!

43 +<<<<<<< .mine
44      if (!to_std)
45 - G_message(_("Eigen values:"));

47 +=======

_______________________________________________
grass-stats mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-stats
hamish-2

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

Reply Threaded More More options
Print post
Permalink
In reply to this post by hamish-2

Nikos:
>    * 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.

to me it picks your eye more quickly if it is not buried in the middle.
shrug. the important thing is that the numbers are correct & not confusing.

>    * Present the loadings (eigenvectors) for each new
> component.

we are doing that already, right?

 
>    * 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 :-)

maybe, but row-wise is slightly easier to code.


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

fancy tables are hard for the module output because it uses G_message()
and G_message() condenses any whitespace (multiple spaces, tabs,..) to a
single space. thus formatting is lost.

and i.pca's main output is maps, not eigen data so I guess it makes sense
to keep that text optional instead of sending to stdout. Perhaps a New flag to print summary report to stdout? (mmph, just cut&paste from history)


for map history it's a bit better, but I can't end with a %.


now 'r.info -h' output looks like:

   Eigen values, (vectors), and [percent importance]:
   PC1   1170.12 ( -0.63 -0.65 -0.43 ) [ 88.07% ]
   PC2    152.49 (  0.23  0.37 -0.90 ) [ 11.48% ]
   PC3      6.01 (  0.75 -0.66 -0.08 ) [  0.45% ]


module output is same but not as pretty due to G_message() issue.


Hamish



     

_______________________________________________
grass-stats mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-stats
Nikos Alexandris

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

Reply Threaded More More options
Print post
Permalink

Nikos:
> >    * 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.

Hamish:
> to me it picks your eye more quickly if it is not buried in the
> middle.
> shrug. the important thing is that the numbers are correct & not
> confusing.

Yes, the important thing are the numbers. A clear output is also more
"functional", if I may say so.



> >    * Present the loadings (eigenvectors) for each new
> > component.

> we are doing that already, right?

Absolutely. It's just the structure of the output what remains. I have
no objections to whatever will be decided as long as the _numbers_ are
there. Nonetheless, from a user's perspective, I presented my ideas
about the output.



> >    * 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 :-)

> maybe, but row-wise is slightly easier to code.

For the interpretation I think the way that the output will look like,
is just a matter to get used to it. In fact, I think row-wise is easier
than column-wise. Anyway, this is of minor importance.



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

> fancy tables are hard for the module output because it uses
> G_message()
> and G_message() condenses any whitespace (multiple spaces, tabs,..) to
> a
> single space. thus formatting is lost.
>
> and i.pca's main output is maps, not eigen data so I guess it makes
> sense
> to keep that text optional instead of sending to stdout. Perhaps a New
> flag to print summary report to stdout? (mmph, just cut&paste from
> history)

> for map history it's a bit better, but I can't end with a %.

> now 'r.info -h' output looks like:
>
>    Eigen values, (vectors), and [percent importance]:
>    PC1   1170.12 ( -0.63 -0.65 -0.43 ) [ 88.07% ]
>    PC2    152.49 (  0.23  0.37 -0.90 ) [ 11.48% ]
>    PC3      6.01 (  0.75 -0.66 -0.08 ) [  0.45% ]
>
>
> module output is same but not as pretty due to G_message() issue.

Well, whatever is practical and achievable. I would be happy to see more
suggestions upon this. But I like it now that it prints out the
eigenvalues.

Best regards, Nikos

_______________________________________________
grass-stats mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-stats
Nikos Alexandris

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

Reply Threaded More More options
Print post
Permalink
In reply to this post by hamish-2

Nikos:
> > It should be the case with i.pca as well since eigen_VALUES_ (=represent
> > the variances of the original dimensions that are "kept" in each
> > component) are important for the interpretation of what exactly are each
> > of the components. But, i.pca just does not report the eigen_VALUES_.
> >
> > At some point some C-expert needs to have a look in the code (i.pca) and
> > correct the "bug" which does not let the eigen_VALUES_ from being
> > printed.

Hamish:

> done in devbr6 (6.5svn) please test, I'm not a multivariate stats guru
> and may have done something dumb so didn't port to other branches yet.
>
> I changed the i.pca output to be like:
>
> 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
>
> As it was previously sent to stderr via G_message() I don't feel bad about
> breaking output text compatibility. I wanted to add "%" to the values but
> due to the sprintf()+strcat() method in the code that was a pain, so I
> didn't.


Wesley:
> > >  If this is the case then both methods still differ significantly. Is
> > > this possible, and which should I use.

> > Please have a look at my comments/questions in link [2].
> > i.pca follows the "SVD" method. You performed the non-standartised PCA
> > using the covariance matrix. Note that you can use also the
> > standartised method by using the correlation matrix.

> does the r.mapcalc command at the end of the m.eigensystem help page*
> do that conversion, or ...? ie how can we test these against each other?
> how to do the standardized method?

We can easily cross-compare now. I will run my test in GRASS and R.
In GRASS:
 * i.pca --> SVD without data centering method

 * "r.covar" + "m.eigensystem" --> non-standardised PCA (about data
centering I am unsure here, I will investigate the _numbers_)

 * "r.covar -r" + "m.eigensystem" # note the "-r" flag --> standardised
PCA (about data centering I am unsure, willing to test).


> [*] (is "\-" there a typo or some old mapcalc syntax?)

IMHO: yes.  Maybe it's some forgotten _backslash_ !?


> also ISTR somebody (Dylan?) doing a comparison with the R-stats interface.
>
>
> It would be nice to run tests using the Spearfish imagery dataset. After
> my own tests I noticed it matched what was used in the m.eigensystem help
> page.

I will probably run the test with my own data. Since I just need to
copy-paste the commands. I don't have the spearfish dataset currently.


> my results follow.
>
> Hamish
>
>
> ----------------------------
> #Spearfish imagery sample dataset
> g.region rast=spot.ms.1
>
>
> # 'by-hand-method'
> G65> echo "3" > test_m.eigensystem    # number of input maps
> G65> r.covar map=spot.ms.1,spot.ms.2,spot.ms.3 >> test_m.eigensystem
>
> G65> cat test_m.eigensystem
> 3
> 462.876649 480.411218 281.758307
> 480.411218 513.015646 278.914813
> 281.758307 278.914813 336.326645
>
>
> G65> m.eigensystem < test_m.eigensystem
> -----
> C The output is N sets of values. One E line and N V W lines
> C
> C  E   real  imaginary   percent-importance
> C  V   real  imaginary
> C  N   real  imaginary
> C  W   real  imaginary
> C      ...
> C
> C where E is the eigen value (and it relative importance)
> C and   V are the eigenvector for this eigenvalue.
> C       N are the normalized eigenvector for this eigenvalue.
> C       W are the N vector multiplied by the square root of the
> C         magnitude of the eigen value (E).
> -----
>
> E      1159.7452017844         0.0000000000    88.38
> V         0.6910021591         0.0000000000
> V         0.7205280412         0.0000000000
> V         0.4805108400         0.0000000000
> N         0.6236808478         0.0000000000
> N         0.6503301526         0.0000000000
> N         0.4336967751         0.0000000000
> W        21.2394712045         0.0000000000
> W        22.1470141296         0.0000000000
> W        14.7695575384         0.0000000000
>
> E         5.9705414972         0.0000000000     0.45
> V         0.7119385973         0.0000000000
> V        -0.6358200627         0.0000000000
> V        -0.0703936743         0.0000000000
> N         0.7438340890         0.0000000000
> N        -0.6643053754         0.0000000000
> N        -0.0735473745         0.0000000000
> W         1.8175356507         0.0000000000
> W        -1.6232096923         0.0000000000
> W        -0.1797107407         0.0000000000
>
> E       146.5031967184         0.0000000000    11.16
> V         0.2265837636         0.0000000000
> V         0.3474697082         0.0000000000
> V        -0.8468727535         0.0000000000
> N         0.2402770238         0.0000000000
> N         0.3684685345         0.0000000000
> N        -0.8980522763         0.0000000000
> W         2.9082771721         0.0000000000
> W         4.4598880523         0.0000000000
> W       -10.8698904856         0.0000000000
>
>
> # 'all-in-one method' using r.covar+m.eigensystem:
> G65> (echo 3; r.covar spot.ms.1,spot.ms.2,spot.ms.3 ) | m.eigensystem
>
> Then, using the W vector, new maps are created:
> r.mapcalc 'pc.1 = 21.2395*map.1 + 22.1470*map.2 + 14.7696*map.3'
> r.mapcalc 'pc.2 =  2.9083*map.1 +  4.4599*map.2  - 10.8699*map.3'
> r.mapcalc 'pc.3 =  1.8175*map.1  -  1.6232*map.2 \-  0.1797*map.3'
>
> (is "\-" above a typo or some old mapcalc syntax?)
Probably a typo.


> which look highly similar (but not identical) to i.pca output maps.
It's ok. R print's out lot's of decimals. Perhaps the difference is due
to some rounding of the numbers.


> (after 'r.colors color=grey')

> # '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

_______________________________________________
grass-stats mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-stats