[R] Signs of loadings from princomp on Windows

Prof Brian Ripley ripley at stats.ox.ac.uk
Tue Sep 14 08:10:50 CEST 2004


I get the second set each time, on Windows, using the build from CRAN.
Which BLAS are you using?

On Tue, 14 Sep 2004, Francisco Chamu wrote:

> I start a clean session of R 1.9.1 on Windows and I run the following code:
> 
> > library(MASS)
> > data(painters)
> > pca.painters <- princomp(painters[ ,1:4])
> > loadings(pca.painters)
> 
> Loadings:
>             Comp.1 Comp.2 Comp.3 Comp.4
> Composition  0.484 -0.376  0.784 -0.101
> Drawing      0.424  0.187 -0.280 -0.841
> Colour      -0.381 -0.845 -0.211 -0.310
> Expression   0.664 -0.330 -0.513  0.432
> 
>                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
> > 
> 
> However, if I rerun the same analysis, the loadings of the first 
> component have the opposite sign (see below), why is that?  I have
> read the note
> in the princomp help that says
> 
>     "The signs of the columns of the loadings and scores are arbitrary,
>      and so may differ between different programs for PCA, and even
>      between different builds of R."
>      
> However, I still would expect the same signs for two runs in the same session.
> 
> > pca.painters <- princomp(painters[ ,1:4])
> > loadings(pca.painters)
> 
> Loadings:
>             Comp.1 Comp.2 Comp.3 Comp.4
> Composition -0.484 -0.376  0.784 -0.101
> Drawing     -0.424  0.187 -0.280 -0.841
> Colour       0.381 -0.845 -0.211 -0.310
> Expression  -0.664 -0.330 -0.513  0.432
> 
>                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
> > 
> > R.version 
>          _              
> platform i386-pc-mingw32
> arch     i386           
> os       mingw32        
> system   i386, mingw32  
> status                  
> major    1              
> minor    9.1            
> year     2004           
> month    06             
> day      21             
> language R              
> > 
> 
> BTW, I have tried the same in R 1.9.1 on Debian and I can't reproduce
> what I see
> on Windows.  In fact all the runs give the same as the second run on Windows.
> 
> -Francisco
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
> 
> 

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595




More information about the R-help mailing list