# [R] Confused by SVD and Eigenvector Decomposition in PCA

Feng Zhang f0z6305 at labs.tamu.edu
Fri Feb 7 18:08:03 CET 2003

```Thanks for those replies.

But I tested several cases, and found the two
percentage from SVD and EVD are not
the same.
So how to explain the difference and which
one should be the right one for use
in PCA?

----- Original Message -----
From: "antonio rodriguez" <arv at ono.com>
To: "Feng Zhang" <f0z6305 at labs.tamu.edu>; "R-Help"
<r-help at stat.math.ethz.ch>
Sent: Friday, February 07, 2003 2:36 AM
Subject: Re: [R] Confused by SVD and Eigenvector Decomposition in PCA

> Hi Feng,
>
> AFIK SVD analysis provides a one-step method for computing all the
> components of the eigen value problem, without the need to compute and
> store big covariance matrices. And also the resulting decomposition is
> computationally more stable and robust.
>
> Cheers,
>
> Antonio Rodriguez
>
>
> ----- Original Message -----
> From: "Feng Zhang" <f0z6305 at labs.tamu.edu>
> To: "R-Help" <r-help at stat.math.ethz.ch>
> Sent: Thursday, February 06, 2003 7:03 PM
> Subject: [R] Confused by SVD and Eigenvector Decomposition in PCA
>
>
> > Hey, All
> >
> > In principal component analysis (PCA), we want to know how many
> percentage
> > the first principal component explain the total variances among the
> data.
> >
> > Assume the data matrix X is zero-meaned, and
> > I used the following procedures:
> > C = covriance(X) %% calculate the covariance matrix;
> > [EVector,EValues]=eig(C) %%
> > L = diag(EValues) %%L is a column vector with eigenvalues as the
> elements
> > percent = L(1)/sum(L);
> >
> >
> > Others argue using Sigular Value Decomposition(SVD) to
> > calculate the same quantity, as:
> > [U,S,V]=svd(X);
> > L = diag(S);
> > L = L.^2;
> > percent = L(1)/sum(L);
> >
> >
> > So which way is the correct method to calculate the percentage
> explained by
> > the first principal component?
> >
> >
> > Fred
> >
> > ______________________________________________
> > R-help at stat.math.ethz.ch mailing list
> > http://www.stat.math.ethz.ch/mailman/listinfo/r-help
>
>
> ---
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> http://www.stat.math.ethz.ch/mailman/listinfo/r-help

```