Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: Principal Components Analysis


From   Stas Kolenikov <[email protected]>
To   [email protected]
Subject   Re: st: Principal Components Analysis
Date   Tue, 13 Jul 2004 18:32:10 -0400 (EDT)

> Does anyone know whether or not STATA can calculate the shares of
> variation in a principal component attributable to its underlying
> variables, or, if STATA cannot do this directly, how to calculate these
> given STATA's output from the "score" command and/or the eigenvectors?

As far as I understand, those would be the squares of the factor loadings.

. pca mpg wei leng
(obs=74)

            (principal components; 3 components retained)
Component    Eigenvalue     Difference    Proportion    Cumulative
------------------------------------------------------------------
     1        2.70121         2.45616      0.9004         0.9004
     2        0.24504         0.19130      0.0817         0.9821
     3        0.05375               .      0.0179         1.0000

               Eigenvectors
    Variable |      1          2          3
-------------+--------------------------------
         mpg |  -0.55448    0.83165    0.03013
      weight |   0.58965    0.36707    0.71943
      length |   0.58726    0.41667   -0.69391

So, the proportion due to mpg is 0.55448^2 = 0.307, etc.

Stata does not save them, so you need to think about ways around it using
the spectral commands Stata has:

. mat accum Cov = mpg wei leng, dev nocons
(obs=74)

. mat li Cov

symmetric Cov[3,3]
               mpg      weight      length
   mpg   2443.4595
weight  -264948.11    44094178
length  -7483.5135   1195077.3   36192.662

. mat Corr = corr(Cov)

. mat li Corr

symmetric Corr[3,3]
               mpg      weight      length
   mpg           1
weight  -.80717486           1
length  -.79577944   .94600864           1

. mat symeigen X V = Corr

. mat li V

V[1,3]
           e1         e2         e3
r1  2.7012074  .24504411  .05374846

. mat li X

X[3,3]
                e1          e2          e3
   mpg  -.55447516   .83165484   .03012519
weight   .58964667   .36706509   .71943035
length   .58725983   .41666948  -.69391097

Now you can access the eigenvalues in the matrix V, and the eigenvectors
(aka factor loadings) in the matrix X.

This is pretty much what Stata does for -pca-, but it formats this stuff
somewhat nicer :)).

 ---                                    Stas Kolenikov
 --       Ph.D. student in Statistics at UNC-Chapel Hill
 - http://www.komkon.org/~tacik/  -- [email protected]

* This e-mail and all attachments to it are not intended to provide any
* reasonable point of view and was transmitted to you in error. It
* should be immediately deleted by all recipients unless they really
* enjoy communicating with the author :). Other restrictions apply.

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index