Re: [R] prcomp - arbitrary direction of the returned principal components

2022-10-13 Thread John C Nash
en > > x = -x > > In this case the positive values will become negative and the negative > > values > > positive. > > Add an if test to selectively rotate based on the value of a single test > > element in x > > (as in x[3,2]). > > > > In debugging or troub

Re: [R] prcomp - arbitrary direction of the returned principal components

2022-10-13 Thread Ashim Kapoor
se set.seed(NULL). > > Tim > > > > -Original Message- > From: Ashim Kapoor > Sent: Thursday, October 13, 2022 12:28 AM > To: Ebert,Timothy Aaron > Cc: R Help > Subject: Re: [R] prcomp - arbitrary direction of the returned principal > components > &g

Re: [R] prcomp - arbitrary direction of the returned principal components

2022-10-13 Thread Ebert,Timothy Aaron
2]). In debugging or trouble shooting setting seed is useful. For actual data analysis you should not set seed, or possibly better yet use set.seed(NULL). Tim -Original Message- From: Ashim Kapoor Sent: Thursday, October 13, 2022 12:28 AM To: Ebert,Timothy Aaron Cc: R Help Subject:

Re: [R] prcomp - arbitrary direction of the returned principal components

2022-10-13 Thread Ivan Krylov
В Wed, 12 Oct 2022 17:18:26 +0530 Ashim Kapoor пишет: > My problem is that I am building an index based on Principal > Components Analysis. > When the index is high it should indicate stress in the market. Have you considered using supervised methods, like PLS, to predict stress in the market?

Re: [R] prcomp - arbitrary direction of the returned principal components

2022-10-12 Thread Chris Evans
,1] is the solution. > Yes it will make the results REPRODUCIBLE but that will be at the > cost > of losing information. > > Any other idea ? > > Many thanks, > Ashim > > On Wed, Oct 12, 2022 at 5:23 PM Ebert,Timothy Aaron > wrote: > > > > Use absol

Re: [R] prcomp - arbitrary direction of the returned principal components

2022-10-12 Thread Ashim Kapoor
> -Original Message- > From: R-help On Behalf Of Ashim Kapoor > Sent: Wednesday, October 12, 2022 7:48 AM > To: R Help > Subject: [R] prcomp - arbitrary direction of the returned principal components > > [External Email] > > Dear R experts, > > From ?prcomp, >

Re: [R] prcomp - arbitrary direction of the returned principal components

2022-10-12 Thread Ebert,Timothy Aaron
Use absolute value Tim -Original Message- From: R-help On Behalf Of Ashim Kapoor Sent: Wednesday, October 12, 2022 7:48 AM To: R Help Subject: [R] prcomp - arbitrary direction of the returned principal components [External Email] Dear R experts, >From ?prcomp, snip - N

[R] prcomp - arbitrary direction of the returned principal components

2022-10-12 Thread Ashim Kapoor
Dear R experts, >From ?prcomp, snip - Note: The signs of the columns of the rotation matrix are arbitrary, and so may differ between different programs for PCA, and even between different builds of R. snip -- My problem is that I am building an index based on Pr

[R] prcomp: Error in La.svd(x, nu, nv): error code 1 from Lapack routine "dgesdd"

2017-05-23 Thread Fix Ace via R-help
Dear R community, I have a data matrix (531X314), and would like to apply the prcomp. However, I got this error Lapack message. I am using R3.2.2. I googled a bit and found that it might be related to converge issue.  Just wonder if there is a way to get around it? Thank you very much! Ace

Re: [R] prcomp() on correlation matrix

2016-11-09 Thread David L Carlson
thropology Texas A&M University College Station, TX 77840-4352 -Original Message- From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Bert Gunter Sent: Wednesday, November 9, 2016 10:58 AM To: T.Riedle Cc: R-help@r-project.org Subject: Re: [R] prcomp() on correlation matrix We

Re: [R] prcomp() on correlation matrix

2016-11-09 Thread David L Carlson
help [mailto:r-help-boun...@r-project.org] On Behalf Of T.Riedle Sent: Wednesday, November 9, 2016 6:46 AM To: R-help@r-project.org Subject: [R] prcomp() on correlation matrix Dear R users, I am trying to do a Principal Components Analysis using the prcomp() function based on the correlation ma

Re: [R] prcomp() on correlation matrix

2016-11-09 Thread Bert Gunter
Well, it seems you can't -- prcomp() seems to want the data matrix. But it would be trivial using svd() -- or possibly even eigen() -- if you understand the underlying linear algebra. Cheers, Bert Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking th

[R] prcomp() on correlation matrix

2016-11-09 Thread T.Riedle
Dear R users, I am trying to do a Principal Components Analysis using the prcomp() function based on the correlation matrix. How can I determine to calculate PCA on a correlation or covariance matrix using prcomp()? Thanks in advance. [[alternative HTML version deleted]]

Re: [R] prcomp(): How do I multiply two matrices

2016-10-07 Thread peter dalgaard
You need to check your theory, and the dimensions of your data structures. Typically, data is (n x p) and your rotation matrix is (p x p) so pre-multiplying by coef1 fits like a round peg in a square hole. Post-multiplying has a better chance, but I have long forgotten whether you need to tran

[R] prcomp(): How do I multiply two matrices

2016-10-07 Thread T.Riedle
Dear R-users, I am trying to do a principal components analysis using the attached data. My code looks as follows. I want to calculate the time series of the principal components (PC) . To this end, I transform the coefficients and the data into matrices and employ a matrix multiplication but i

Re: [R] prcomp - surprising structure

2013-10-04 Thread peter dalgaard
On Oct 3, 2013, at 16:30 , Hermann Norpois wrote: > Thanks for answering. > > I already started hunting. But my first doubt was if I used prcomp correctly > (and this is in the moment my most important point). So far as I understood > your answer is yes. Is that correct? Yes. There are a cou

Re: [R] prcomp - surprising structure

2013-10-03 Thread Hermann Norpois
Thanks for answering. I already started hunting. But my first doubt was if I used prcomp correctly (and this is in the moment my most important point). So far as I understood your answer is yes. Is that correct? I am puzzled by the fact that these "columns" are more or less in the middle of my sn

Re: [R] prcomp - surprising structure

2013-10-03 Thread peter dalgaard
It's not so obvious to me that this is an artifact. What prcomp() says is that some of the eigenvectors have a lot of "activity" in some relatively narrow ranges of SNPs (on the same chromosome, perhaps?). If something artificial is going on, I could imagine effects not so much of centering colu

[R] prcomp - surprising structure

2013-10-03 Thread Hermann Norpois
Hello, I did a pca with over 20 snps for 340 observations (ids). If I plot the eigenvectors (called rotation in prcomp) 2,3 and 4 (e.g. plot (rotation[,2]) I see a strange "column" in my data (see attachment). I suggest it is an artefact (but of what?). Suggestion: I used prcomp this way: prc

Re: [R] prcomp( and cmdscale( not equivalent?

2013-04-29 Thread David Carlson
ciate Professor of Anthropology Texas A&M University College Station, TX 77840-4352 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Bob Wiley Sent: Friday, April 26, 2013 4:33 PM To: r-help@r-project.org Subject: [R] prcomp( and cmds

[R] prcomp( and cmdscale( not equivalent?

2013-04-26 Thread Bob Wiley
Hello, I have a dilemma that I'm hoping the R gurus will be able to help resolve. For background: My data is in the form of a (dis)similarity matrix created from taking the inverse of normalized reaction times. That is, each cell of the matrix represents how long it took to distinguish two stimuli

Re: [R] prcomp() and varimax()

2013-04-07 Thread peter dalgaard
On Apr 7, 2013, at 16:06 , Mike Amato wrote: > Thanks for the reply. Maybe my problem is that prcomp() and varimax() > are calculating "cumulative proportion of variance" differently? > When I use the tol parameter with prcomp(), it restricts the number of > components to 3 and reports that the

Re: [R] prcomp() and varimax()

2013-04-07 Thread Mike Amato
Thanks for the reply. Maybe my problem is that prcomp() and varimax() are calculating "cumulative proportion of variance" differently? When I use the tol parameter with prcomp(), it restricts the number of components to 3 and reports that the cumulative variance explained by the third component

Re: [R] prcomp() and varimax()

2013-04-07 Thread S Ellison
> > My concern is with the reported proportions of variance for the 3 > components after varimax rotation. It looks like each of my 3 components > explains 1/15 of the total variance, summing to a cumulative proportion > of 20% of variance explained. But those 3 components I retained should >

[R] prcomp() and varimax()

2013-04-04 Thread Mike Amato
Hello, I am attempting to do a principal components analysis on 15 survey items. I want to use a varimax rotation on the retained components, but I am dubious of the output I am getting, and so I suspect I am doing something wrong. I proceed in the following steps: 1) use prcomp() to inspect

Re: [R] prcomp: where do sdev values come from?

2012-06-21 Thread David L Carlson
roject.org [mailto:r-help-bounces@r- > project.org] On Behalf Of Adams, Sky > Sent: Wednesday, June 20, 2012 3:15 PM > To: r-help@r-project.org > Subject: [R] prcomp: where do sdev values come from? > > In the manual page for prcomp(), it says that sdev is "the standard &g

[R] prcomp

2012-06-21 Thread carol white
Hi, If center=T (by default) in invoking prcomp, that is, prcomp (x) where x is a matrix with the observations are in rows and the variables are in column, is this equivalent to scale(t(x),center=T,scale=F) where x is a matrix with the observations are in rows and the variables are in columns?

[R] prcomp: where do sdev values come from?

2012-06-20 Thread Adams, Sky
In the manual page for prcomp(), it says that sdev is "the standard deviations of the principal components (i.e., the square roots of the eigenvalues of the covariance/correlation matrix, though the calculation is actually done with the singular values of the data matrix)."  However, this is not wh

Re: [R] prcomp: results with reversed sign in output?

2011-09-10 Thread Vokey, John
In addition, many PCA packages follow the convention that if the majority of weights are negative for that component, reverse the sign. On 2011-09-10, at 4:00 AM, r-help-requ...@r-project.org wrote: > The point is that a principal component vector is a solution, > say V, of a matrix equation A%*

Re: [R] prcomp: results with reversed sign in output?

2011-09-09 Thread René Mayer
thanks for explaining Duncan and Ted, Indeed, I did compare my results from a textbook and noticed that I consitenly get flipped signs and biplots. regards René Zitat von ted.hard...@wlandres.net: The point is that a principal component vector is a solution, say V, of a matrix equation A%*%V

Re: [R] prcomp: results with reversed sign in output?

2011-09-09 Thread Ted Harding
The point is that a principal component vector is a solution, say V, of a matrix equation A%*%V = L*V where A is the matrix and L is a scalar.. Since this equation can be written A%*%(-V) = L*(-V), the result is indeterminate with respect to its sign. If V is a solution, so is (-V), and vice versa

Re: [R] prcomp: results with reversed sign in output?

2011-09-09 Thread Duncan Murdoch
On 11-09-09 5:42 AM, René Mayer wrote: thanks for pointing out Paul, but the thing which is annoying me in the first place IS this direction reversal. this makes no sense for me why could this be? I think you need to read more about principal components. The signs within a PC vector are meani

Re: [R] prcomp: results with reversed sign in output?

2011-09-09 Thread René Mayer
thanks for pointing out Paul, but the thing which is annoying me in the first place IS this direction reversal. this makes no sense for me why could this be? Zitat von "Paul Hiemstra" : Hi, If all the signs are switched the PC's are still the same. The principal vectors are along the same

Re: [R] prcomp: results with reversed sign in output?

2011-09-09 Thread Paul Hiemstra
Hi, If all the signs are switched the PC's are still the same. The principal vectors are along the same axis, only in a different direction. So there is no problem :). hope this helps, Paul On 09/09/2011 09:01 AM, René Mayer wrote: > Dear All, > > when I'm running a PCA with > > prcomp(USArrest

[R] prcomp: results with reversed sign in output?

2011-09-09 Thread René Mayer
Dear All, when I'm running a PCA with prcomp(USArrests, scale = TRUE) I get the right principal components, but with the wrong sign infront Rotation: PC1 PC2 PC3 PC4 Murder 0.5358995 -0.4181809 0.3412327 0.64922780 Assault 0.5831836 -0.1879856 0.2681484 -0.74340748 UrbanPop 0.2781909 0.8728062

Re: [R] prcomp

2011-08-18 Thread David L Carlson
Texas A&M University College Station, TX 77843-4352 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of David Winsemius Sent: Wednesday, August 17, 2011 5:03 PM To: David Winsemius Cc: r-help@r-project.org; Rosario Garcia Gil Subj

Re: [R] prcomp

2011-08-17 Thread David Winsemius
On Aug 17, 2011, at 5:47 PM, David Winsemius wrote: On Aug 17, 2011, at 5:19 PM, Rosario Garcia Gil wrote: Hello I am trying to run a PCA on the attached file, but I get this error message: pc<-prcomp(data[,-(1:2)],scale=T)$x Error in svd(x, nu = 0) : infinite or missing values in 'x'

Re: [R] prcomp

2011-08-17 Thread David Winsemius
On Aug 17, 2011, at 5:19 PM, Rosario Garcia Gil wrote: Hello I am trying to run a PCA on the attached file, but I get this error message: pc<-prcomp(data[,-(1:2)],scale=T)$x Error in svd(x, nu = 0) : infinite or missing values in 'x' What part of "missing values in 'x'" is unclear in tha

[R] prcomp

2011-08-17 Thread Rosario Garcia Gil
Hello I am trying to run a PCA on the attached file, but I get this error message: pc<-prcomp(data[,-(1:2)],scale=T)$x Error in svd(x, nu = 0) : infinite or missing values in 'x' Thanks in advance /R x y x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 x14 1 25.49 45.62 125 156 165 130 179 152 82 165

Re: [R] prcomp & eigenvectors ... ??

2011-05-30 Thread peter dalgaard
On May 28, 2011, at 20:08 , Natalie Stephenson wrote: > Hi ... > > Please could you help with probably a very simple problem I have. I'm > completely new to R and am trying to follow a tutorial using R for Force > Distribution Analysis that I got from ... > http://projects.eml.org/mbm/websit

[R] prcomp & eigenvectors ... ??

2011-05-28 Thread Natalie Stephenson
Hi ... Please could you help with probably a very simple problem I have. I'm completely new to R and am trying to follow a tutorial using R for Force Distribution Analysis that I got from ... http://projects.eml.org/mbm/website/fda_gromacs.htm. Basically, the MDS I preform outputs a force m

Re: [R] prcomp function

2010-11-11 Thread kicker
Dear Claudia, you are right. Thank you very much for your explanations. So in the non-centered case SDEV does not contain the "square roots of the eigenvalues of the covariance/correlation matrix". In in the centered case it holds A´A=(n-1)*cov(A) (not n+1). Have a nice day. -- View this messa

Re: [R] prcomp function

2010-11-10 Thread Claudia Beleites
I think PCA decomposes matrix A according to A'A, not to COV (A). But if A is centered then A'A = (n + 1) COV (A). So for non-centered A, you want to look at A'A instead: > crossprod(A) %*% evec[,1] / (nrow (A) - 1) - eval [1] * evec [,1] [,1] [1,] 0.000e+00 [2,] 0.000e+00 [3,] 1.066e

[R] prcomp function

2010-11-10 Thread kicker
Hello, I have a short question about the prcomp function. First I cite the associated help page (help(prcomp)): "Value: ... SDEV the standard deviations of the principal components (i.e., the square roots of the eigenvalues of the covariance/correlation matrix, though the calculation is actually

Re: [R] prcomp() and the lenght of PC:s

2010-06-16 Thread Prof Brian Ripley
What do you mean by 'lenght'? It is part of the definition that the coefficient vector has Euclidean length one: a principal component is a projection. See for example MASS p.302. I don't see anything that has length 1 in the R sense. On Wed, 16 Jun 2010, Atte Tenkanen wrote: Hi, I would

[R] prcomp() and the lenght of PC:s

2010-06-16 Thread Atte Tenkanen
Hi, I would like to know whether there is some deeper rationale behind or is it just an established practice that the lenghts of principal components, giving for example by prcomp-function, are normalised to 1? Best regards, Atte Tenkanen University of Turku, Finland Department of Musicology +

Re: [R] prcomp : plotting only explanatory axis arrows

2009-12-24 Thread Prof Brian Ripley
First, this is about biplot, not prcomp. Second, you seem to want to get a single-variable plot out of a biplot, which contradicts the 'bi' and hence I would not expect there to be a simple way to do this. The simplest thing to do would be to edit biplot.default via biplot.default <- stats::

[R] prcomp : plotting only explanatory axis arrows

2009-12-23 Thread milton ruser
Dear all, I have a very large dataset (1712351 , 20) and would like to plot only the arrows that represent the contribution of each variables. On the sample below I woild like to plot only the explanatory variables (Murder, Assault..) and not the sites. prcomp(USArrests) # inappropriate prcomp(U

[R] prcomp() PCA vs fastICA() PCA?

2009-11-11 Thread Joel Fürstenberg-Hägg
Hi all, I wonder what the difference is between the functions prcomp and the PCA plotting method used in example 3 from the fastICA package. They give totally different plots. The reason for asking is that I've earlier used prcomp, but now I should do an ICA, and I guess I cannot compare th

Re: [R] prcomp - principal components in R

2009-11-09 Thread Tony Plate
The output of summary prcomp displays the cumulative amount of variance explained relative to the total variance explained by the principal components PRESENT in the object. So, it is always guaranteed to be at 100% for the last principal component present. You can see this from the code in s

Re: [R] prcomp - principal components in R

2009-11-09 Thread markleeds
> cuncta stricte discussurus > - > > -Ursprüngliche Nachricht- > Von: [1]r-help-boun...@r-project.org [[2]mailto:r-help-boun...@r-project.org] Im > Auftrag von zubin > Gesendet: Monday, November 09, 2009 12:37

Re: [R] prcomp - principal components in R

2009-11-09 Thread zubin
--- cuncta stricte discussurus - -Ursprüngliche Nachricht- Von: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Im Auftrag von zubin Gesendet: Monday, November 09, 2009 12:37 PM An: r-help@r-project.org Betreff: [R] prcomp - principal compone

Re: [R] prcomp - principal components in R

2009-11-09 Thread Daniel Malter
-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Im Auftrag von zubin Gesendet: Monday, November 09, 2009 12:37 PM An: r-help@r-project.org Betreff: [R] prcomp - principal components in R Hello, not understanding the output of prcomp, I reduce the number of components and the output co

Re: [R] prcomp - principal components in R

2009-11-09 Thread stephen sefick
Look at it linearly? On Mon, Nov 9, 2009 at 11:45 AM, zubin wrote: > okay, an extreme case, only 1 component, explains 100%, something weird > going on.. > >  > princ = prcomp(df[,-1],rotate="varimax",scale=TRUE,tol=.95) >  > summary(princ) > Importance of components: >                        PC1

Re: [R] prcomp - principal components in R

2009-11-09 Thread zubin
okay, an extreme case, only 1 component, explains 100%, something weird going on.. > princ = prcomp(df[,-1],rotate="varimax",scale=TRUE,tol=.95) > summary(princ) Importance of components: PC1 Standard deviation 1.38 Proportion of Variance 1.00 Cumulative Proportion

Re: [R] prcomp - principal components in R

2009-11-09 Thread stephen sefick
principal components is a data reduction technique. It looks like you have three axes that account for 100%. Make this reporducible. On Mon, Nov 9, 2009 at 11:37 AM, zubin wrote: > Hello, not understanding the output of prcomp, I reduce the number of > components and the output continues to sh

[R] prcomp - principal components in R

2009-11-09 Thread zubin
Hello, not understanding the output of prcomp, I reduce the number of components and the output continues to show cumulative 100% of the variance explained, which can't be the case dropping from 8 components to 3. How do i get the output in terms of the cumulative % of the total variance, so

Re: [R] prcomp(X,center=F) ??

2009-03-08 Thread Jari Oksanen
Dear Agustin & the Listers, Noncentred PCA is an old and establishes method. It is rarely used, but still (methinks) it is used more often than it should be used. There is nothing wrong in having noncentred PCA in R, and it is a real PCA. Details will follow. On 08/03/2009, at 11:07 AM, A

Re: [R] prcomp(X,center=F) ??

2009-03-08 Thread Mark Difford
Hi Agus, >> But the rotation made with the eigenvectors of prcomp(X,center=F) yields >> axes that are correlated. Therefore, prcomp(X,center=F) is not really a >> PCA. cor() is not an appropriate test of whether two vectors are orthogonal. The definition that two vectors (in an inner product sp

[R] prcomp(X,center=F) ??

2009-03-08 Thread Agustin Lobo
I do not understand, from a PCA point of view, the option center=F of prcomp() According to the help page, the calculation in prcomp() "is done by a singular value decomposition of the (centered and possibly scaled) data matrix, not by using eigen on the covariance matrix" (as it's done by p

Re: [R] prcomp vs. princomp vs fast.prcomp

2008-02-10 Thread Liviu Andronic
On 2/10/08, Erin Hodgess <[EMAIL PROTECTED]> wrote: > When performing PCA, should I use prcomp, princomp or fast.prcomp, please? You can take a look here [1] and here [2] for some short references. >From the first page: "Principal Components Analysis (PCA) is available in prcomp() (preferred) and

[R] prcomp vs. princomp vs fast.prcomp

2008-02-10 Thread Erin Hodgess
Hi R People: When performing PCA, should I use prcomp, princomp or fast.prcomp, please? thanks. Erin -- Erin Hodgess Associate Professor Department of Computer and Mathematical Sciences University of Houston - Downtown mailto: [EMAIL PROTECTED] __ R