Hi Sas,
Yes, your approach makes sense and is a common method for projecting new data onto the principal component space derived from another dataset. You can use Singular Value Decomposition (SVD) results from group1 to project group2 onto the same principal component space. Here’s how you can do it:
1) Perform SVD on group1:
- You've already done this with [u, s, v] = svd(group1).
- u contains the left singular vectors (principal directions) for group1.
- s contains the singular values.
- v contains the right singular vectors.
2) Identify the Principal Component:
- Since you mentioned that one principal component explains most of the variance, you will focus on the first column of u (i.e., u(:, 1)).
3) Project group2 onto the Principal Component:
- To project group2 onto the principal component space of group1, use the first singular vector (u(:, 1)) as the basis for projection.
- Multiply group2 by the principal component direction to obtain the projection scores.
% Assuming `group1` is 25x2000 and `group2` is 12x2000
[u, s, v] = svd(group1, 'econ'); % 'econ' for economy size decomposition
% Project group2 onto the first principal component of group1
principalComponent1 = u(:, 1); % First principal component direction
group2Projection = group2 * principalComponent1; % Projection scores
4) Analysis:
- The group2Projection vector contains the projection scores of group2 onto the first principal component of group1.
- You can compare these scores with the projection scores of group1 to see if the first principal component separates the two groups.
5) Visualization:
- Plot the projection scores to visualize the separation:
% Project group1 onto its first principal component for comparison
group1Projection = group1 * principalComponent1;
% Plot the projections
figure;
hold on;
histogram(group1Projection, 'FaceColor', 'b', 'DisplayName', 'Group 1');
histogram(group2Projection, 'FaceColor', 'r', 'DisplayName', 'Group 2');
xlabel('Projection Score');
ylabel('Frequency');
title('Projection of Groups onto First Principal Component');
legend show;
hold off;
