11

Example code:

(pc.cr <- princomp(USArrests))  
summary(pc.cr)
loadings(pc.cr)  ## note that blank entries are small but not zero

I am getting different outputs from each, and I am not sure I understand what the difference is.

Here is the output:

> summary(pc.cr)
Importance of components:
                           Comp.1      Comp.2      Comp.3       Comp.4
Standard deviation     82.8908472 14.06956001 6.424204055 2.4578367034
Proportion of Variance  0.9655342  0.02781734 0.005799535 0.0008489079
Cumulative Proportion   0.9655342  0.99335156 0.999151092 1.0000000000


> loadings(pc.cr)  ## note that blank entries are small but not zero

...

               Comp.1 Comp.2 Comp.3 Comp.4
SS loadings      1.00   1.00   1.00   1.00
Proportion Var   0.25   0.25   0.25   0.25
Cumulative Var   0.25   0.50   0.75   1.00

P.S: how can I get access to the table created by summary(pc.cr)?? (I can't seem to find it in str.)

Tal Galili
  • 19,935
  • 32
  • 133
  • 195

1 Answers1

4

The first output is the correct and most useful one. Calling loadings() on your object just returns a summary where the SS are always equal to 1, hence the % variance is just the SS loadings divided by the number of variables. It makes sense only when using Factor Analysis (like in factanal). I never use princomp or its SVD-based alternative (prcomp), and I prefer the FactoMineR or ade4 package which are by far more powerful!

About your second question, the summary() function just returns the SD for each component (pc.cr$sdev in your case), and the rest of the table seems to be computed afterwards (through the print or show method, I didn't investigate this in details).

> getS3method("summary","princomp")
function (object, loadings = FALSE, cutoff = 0.1, ...)
{
    object$cutoff <- cutoff
    object$print.loadings <- loadings
    class(object) <- "summary.princomp"
    object
}
<environment: namespace:stats>

What princomp() itself does may be viewed using getAnywhere("princomp.default").

chl
  • 50,972
  • 18
  • 205
  • 364
  • +1 I also use FactoMineR but I remember that when I tried it's PCA method on a really large dataset, I never got results. – George Dontas Sep 19 '10 at 18:11
  • @gd047 It failed for me too, though it is based on an SVD (might be optimized to handle large data set :) – chl Sep 19 '10 at 18:26