Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

As far as I can see PrincipalComponents[data] just gives data in the principal component basis. The problem is that after this, I would like to transform new data into the same basis, which requires that I know the actual principal components.

There is the option of calculating Eigenvectors[Covariance[data]] (given the data is centered on the origin) but for the eigenvectors I get this way the signs are usually different from the ones that the PrincipalComponents[] function uses.

Is there an easy way of getting the actual transformation used or transforming new data into the PC basis of the previous dataset?

share|improve this question
add comment

1 Answer 1

up vote 5 down vote accepted

You can do it with FindGeometricTransform[]:

data = {{13.2, 200, 58, 21.2}, {10, 263, 48, 44.5}, {8.1, 294, 80, 31}, 
        {8.8, 190, 50, 19.5}, {9, 276, 91, 40.6}, {7.9, 204, 78, 38.7}, 
        {3.3, 110, 77, 11.1}, {5.9, 238, 72, 15.8}, {15.4, 335, 80, 31.9}, {17.4, 211, 60, 25.8}};
{error, f} = FindGeometricTransform[PrincipalComponents[data], data];
Norm[PrincipalComponents[data][[1]] - f[data[[1]]]]
(*
  0.8
*)

enter image description here

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.