Thread Subject: Difference between processpca and princomp

Subject: Difference between processpca and princomp

From: John

Date: 12 Sep, 2011 11:52:14

Message: 1 of 2

Hi all,

I'm using PCA to reduce the dimensionality of my data to train a SOM. To check I was processing the data correctly, I thought I'd check if processpca and princomp give the same data in PCA space. Thing is they don't, anyone know why? As a test I set up a simple matrix:


>> matrix = [1 4 8; 10 5 8; 18 4 8];

Then used princomp and printed out the data in PC space:


>> [pcs, pc_data, latents] = princomp(matrix);

>> pc_data =

   -8.6674 0.3133 0
    0.3349 -0.6659 0
    8.3325 0.3526 0

Then used processpca and printed out the data in PC space:

>> [pcs2, pca_settings] = processpca(matrix);

>> pcs2 =

  -20.1263 -6.9170 -12.7358
   -4.4646 2.9594 5.4482
   -0.0000 -0.6307 0.3426

I would expect both to be the same, any ideas on why they aren't?

Subject: Difference between processpca and princomp

From: Greg Heath

Date: 12 Sep, 2011 19:27:43

Message: 2 of 2

On Sep 12, 7:52 am, "John " <re...@epsam.keele.ac.uk> wrote:
> Hi all,
>
> I'm using PCA to reduce the dimensionality of my data to train a SOM.  To check I was processing the data correctly, I thought I'd check if processpca and princomp give the same data in PCA space.  Thing is they don't, anyone know why?  As a test I set up a simple matrix:
>
> >> matrix = [1 4 8; 10 5 8; 18 4 8];
>
> Then used princomp and printed out the data in PC space:
>
> >> [pcs, pc_data, latents] = princomp(matrix);
> >> pc_data =
>
>    -8.6674    0.3133         0
>     0.3349   -0.6659         0
>     8.3325    0.3526         0
>
> Then used processpca and printed out the data in PC space:
>
> >> [pcs2, pca_settings] = processpca(matrix);
> >> pcs2 =
>
>   -20.1263   -6.9170  -12.7358
>    -4.4646    2.9594    5.4482
>    -0.0000   -0.6307    0.3426
>
> I would expect both to be the same, any ideas on why they aren't?

Read the documentation closely. Does one of them assume the
data has zero mean?

Hope this helps.

Greg

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
pca John 12 Sep, 2011 07:54:16
processpca John 12 Sep, 2011 07:54:16
princomp John 12 Sep, 2011 07:54:16
neural network John 12 Sep, 2011 07:54:16
preprocess data John 12 Sep, 2011 07:54:16
rssFeed for this Thread

Contact us at files@mathworks.com