Thread Subject: Re-applying princomp loadings

Subject: Re-applying princomp loadings

From: Giorgos Tzampanakis

Date: 27 Mar, 2010 20:13:59

Message: 1 of 4

How can I use the loadings returned by princomp to project new
data to the space given by them?

For example, I have a set of data that I give to princomp and
obtain the loadings and the projected data to the PCA space. Now
I have a new set of data, and I want to project it to the same
space. How can I do that?

Subject: Re-applying princomp loadings

From: Doug Schwarz

Date: 27 Mar, 2010 21:37:46

Message: 2 of 4

In article <Xns9D48CDD33DC77fdnbgui7uhu5h8hrnuio@127.0.0.1>,
 Giorgos Tzampanakis <gt67@hw.ac.uk> wrote:

> How can I use the loadings returned by princomp to project new
> data to the space given by them?
>
> For example, I have a set of data that I give to princomp and
> obtain the loadings and the projected data to the PCA space. Now
> I have a new set of data, and I want to project it to the same
> space. How can I do that?

[coeff,scores_x] = princomp(x);
scores_y = y*coeff;

You might want to subtract the column means from y first.

--
Doug Schwarz
dmschwarz&ieee,org
Make obvious changes to get real email address.

Subject: Re-applying princomp loadings

From: Simara

Date: 17 Dec, 2011 21:06:08

Message: 3 of 4

Doug Schwarz <see@sig.for.address.edu> wrote in message
> [coeff,scores_x] = princomp(x);
> scores_y = y*coeff;
>
> You might want to subtract the column means from y first.
>
> --
> Doug Schwarz
> dmschwarz&ieee,org
> Make obvious changes to get real email address.

Hello,

I also want to project a new set of data onto the same space I previously obtained by using princomp. I tried your recomendation but I don't get good results. I tried the folowing with the original data "x":

Substracting the mean value of columns of "x" and then " scores_x2 = x*coeff; "

but scores_x2 does not hold the same values as the original output of the princomp fuction (scores_x). I also tried multiplying scores_x2 by the respectives eigenvalues but this doesn't seems to work either.

Thank you very much for your help.

Subject: Re-applying princomp loadings

From: Jacob

Date: 5 Apr, 2012 00:05:21

Message: 4 of 4

"Simara" wrote in message <jcj07v$piu$1@newscl01ah.mathworks.com>...
> Hello,
>
> I also want to project a new set of data onto the same space I previously obtained by using princomp. I tried your recomendation but I don't get good results. I tried the folowing with the original data "x":
>
> Substracting the mean value of columns of "x" and then " scores_x2 = x*coeff; "
>
> but scores_x2 does not hold the same values as the original output of the princomp fuction (scores_x). I also tried multiplying scores_x2 by the respectives eigenvalues but this doesn't seems to work either.
>
> Thank you very much for your help.

In case anyone finds this as I did, the abov method works;
[coeff, score] = princomp(olddata);
score_new = (newdata - mean(olddata,1)) * coeff;

See also
http://tipstrickshowtos.blogspot.com/2012/01/additional-help-with-matlabprincomp.html

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 Simara 17 Dec, 2011 16:09:09
eigenvectors Simara 17 Dec, 2011 16:09:09
eigenvalues Simara 17 Dec, 2011 16:09:09
scores Simara 17 Dec, 2011 16:09:09
rssFeed for this Thread

Contact us at files@mathworks.com