Why do I get different loadings in FactoMineR PCA() than in the princomp() and prcomp() functions?

3,023 views
Skip to first unread message

Thomas Browne

unread,
Aug 18, 2012, 8:20:04 AM8/18/12
to factomin...@googlegroups.com
Hello, 

I have a matrix of 28 daily return series going back 10 years. I am trying to do a basic principal components analysis on it using to extract the most important component, and I like the fact that FactoMineR allows me to weight columns and rows. However before I do this I note that FactoMineR's PCA() function produces different results than princomp or prcomp. Here are the first PC loadings using all three functions:

> prcomp(retmat)$rotation[, 1]
        USD         EUR         GBP         CHF         CAD         AUD         NZD         JPY         NOK         SEK         CZK         PLN 
-0.26789024  0.05197828 -0.01033208 -0.13493934  0.05716836  0.22781242  0.18587684 -0.48284826  0.13113881  0.14136272  0.14612338  0.29205309 
        HUF         RON         RUB         TRY         ZAR         ILS         SGD         INR         IDR         KRW         TWD         PHP 
 0.31371401  0.10179189 -0.04098824  0.18257525  0.31384143 -0.11753567 -0.13835174 -0.13387606 -0.14938836  0.05604098 -0.20157527 -0.15080040 
        MXN         BRL         CLP         COP 
 0.08658325  0.22146970 -0.03881396 -0.02192588 

> summary(princomp(retmat))$loadings[, 1]
        USD         EUR         GBP         CHF         CAD         AUD         NZD         JPY         NOK         SEK         CZK         PLN 
 0.26789024 -0.05197828  0.01033208  0.13493934 -0.05716836 -0.22781242 -0.18587684  0.48284826 -0.13113881 -0.14136272 -0.14612338 -0.29205309 
        HUF         RON         RUB         TRY         ZAR         ILS         SGD         INR         IDR         KRW         TWD         PHP 
-0.31371401 -0.10179189  0.04098824 -0.18257525 -0.31384143  0.11753567  0.13835174  0.13387606  0.14938836 -0.05604098  0.20157527  0.15080040 
        MXN         BRL         CLP         COP 
-0.08658325 -0.22146970  0.03881396  0.02192588 

> PCA(retmat, scale.unit = FALSE, graph = FALSE)$var$coord[, 1]
          USD           EUR           GBP           CHF           CAD           AUD           NZD           JPY           NOK           SEK 
-0.0040704452  0.0007897815 -0.0001569903 -0.0020503293  0.0008686419  0.0034614848  0.0028242967 -0.0073366144  0.0019925823  0.0021479289 
          CZK           PLN           HUF           RON           RUB           TRY           ZAR           ILS           SGD           INR 
 0.0022202646  0.0044375865  0.0047667123  0.0015466719 -0.0006227939  0.0027741308  0.0047686483 -0.0017858900 -0.0021021787 -0.0020341733 
          IDR           KRW           TWD           PHP           MXN           BRL           CLP           COP 
-0.0022698742  0.0008515119 -0.0030628257 -0.0022913293  0.0013155849  0.0033651105 -0.0005897569 -0.0003331518 

As you can see prcomp and princomp both produce the same loadings, consistent with the eigen(cov()) functions, but PCA() produces a result which is scaled by a factor of around 0.015.

> PCA(retmat, scale.unit = FALSE, graph = FALSE)$var$coord[, 1] / prcomp(retmat)$rotation[, 1]
       USD        EUR        GBP        CHF        CAD        AUD        NZD        JPY        NOK        SEK        CZK        PLN        HUF 
0.01519445 0.01519445 0.01519445 0.01519445 0.01519445 0.01519445 0.01519445 0.01519445 0.01519445 0.01519445 0.01519445 0.01519445 0.01519445 
       RON        RUB        TRY        ZAR        ILS        SGD        INR        IDR        KRW        TWD        PHP        MXN        BRL 
0.01519445 0.01519445 0.01519445 0.01519445 0.01519445 0.01519445 0.01519445 0.01519445 0.01519445 0.01519445 0.01519445 0.01519445 0.01519445 
       CLP        COP 
0.01519445 0.01519445 

I want to stick with FactoMineR because I like it's ability to weight both columns and rows, but I would like to know why it has scaled the result in this way and what that means? Perhaps I am forgetting a parameter somewhere?

Thank you for any help.  

Thomas Browne

unread,
Aug 18, 2012, 8:48:16 AM8/18/12
to factomin...@googlegroups.com

Here by the way (attached) is the data, retmat.r

you can load it using the load command
retmat.r

François Husson

unread,
Aug 18, 2012, 9:03:25 AM8/18/12
to factomin...@googlegroups.com
Dear Thomas,

The difference is that FactoMineR does not return the loadings but the coordinates of the variables (you can divide the results of PCA by the square root of the eigenvalue of each dimension to recover the loadings):

res <- PCA(retmat, scale.unit = FALSE, graph = FALSE)
loadings<-sweep(res$var$coord,2,sqrt(res$eig[1:5,1]),FUN="/")

Best
Francois

Thomas Browne

unread,
Aug 18, 2012, 3:45:15 PM8/18/12
to factomin...@googlegroups.com
Thank you very much. I should have know this really. 
Reply all
Reply to author
Forward
0 new messages