[R] How to plot PCA output?

Jessica Streicher j.streicher at micromata.de
Mon May 7 16:25:29 CEST 2012


And i always forget the question..

I haven't understood biplots a 100%, but from what i gleaned this scaling is done so it looks better/is easier to read, while the scaling retains certain properties of the biplot (something about projecting).

If you want to use the data for anything else, i wouldn't use that scaling, just use what the prcomp() or princomp() function returns to you.


Am 07.05.2012 um 16:11 schrieb Jessica Streicher:

> Biplot, depending on what parameters you give it, scales the data in a certain way.
> 
> See http://stat.ethz.ch/R-manual/R-patched/library/stats/html/biplot.princomp.html
> 
> scale
> The variables are scaled by lambda ^ scale and the observations are scaled by lambda ^ (1-scale) where lambda are the singular values as computed by princomp. Normally 0 <= scale <= 1, and a warning will be issued if the specified scale is outside this range. 
> 
> 
> 
> Am 07.05.2012 um 16:01 schrieb Christian Cole:
> 
>> Hi Jessica,
>> 
>> Yes, that does help. It confirms my digging around in the prcomp object.
>> 
>> I was plotting $x, but wasn't sure whether this was appropriate. Mainly
>> because the data ranges are different in $x than when plotted by biplot()
>> - as I mentioned my reply to Bryan. Do you know if this difference is data
>> range matters?
>> Many thanks,
>> 
>> Chris
>> 
>> 
>> 
>> On 07/05/2012 14:24, "Jessica Streicher" <j.streicher at micromata.de> wrote:
>> 
>>> That depends on what you want to plot there. Basically, you could just
>>> use plot() with pcaResult$x. You might need to define which PCs you want
>>> to plot there though.
>>> 
>>> pcaResult<-prcomp(iris[,1:4])
>>> plot(pcaResult$x) # gives the first 2 PCs
>>> plot(pcaResult$x[,2:3]) #gives the second vs the 3rd PC
>>> 
>>> or if you want to see more you can use pairs()
>>> 
>>> pairs(pcaResult$x)
>>> 
>>> if you want things colored, theres the col parameter that works for both
>>> functions:
>>> 
>>> pairs(pcaResult$x,col=iris[,5])
>>> 
>>> Does this help?
>>> 
>>> Am 07.05.2012 um 12:22 schrieb Christian Cole:
>>> 
>>>> I have a decent sized matrix (36 x 11,000) that I have preformed a PCA
>>>> on
>>>> with prcomp(), but due to the large number of variables I can't plot the
>>>> result with biplot(). How else can I plot the PCA output?
>>>> 
>>>> I tried posting this before, but got no responses so I'm trying again.
>>>> Surely this is a common problem, but  I can't find a solution with
>>>> google?
>>>> 
>>>> 
>>>> The University of Dundee is a registered Scottish Charity, No: SC015096
>>>> 
>>>> ______________________________________________
>>>> R-help at r-project.org mailing list
>>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>>> PLEASE do read the posting guide
>>>> http://www.R-project.org/posting-guide.html
>>>> and provide commented, minimal, self-contained, reproducible code.
>>> 
>>> ______________________________________________
>>> R-help at r-project.org mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>> PLEASE do read the posting guide
>>> http://www.R-project.org/posting-guide.html
>>> and provide commented, minimal, self-contained, reproducible code.
>>> 
>> 
>> 
>> The University of Dundee is a registered Scottish Charity, No: SC015096
>> 
> 
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list