PCA using Matlab, SPSS
Hi
Following is the program I run for PCA. For the same set of data I tried PCA with various rotations in SPSS. But nothing gave the same plot as matlab did. Am I making any mistake in the program or why is the difference?
A=xlsread(‘sn30.xlsx’);A = A’;
[n m] = size(A);
AMean = mean(A);
AStd = std(A);
B = (A – repmat(AMean,[n 1])) ./ repmat(AStd,[n 1]);
[COEFF SCORE LATENT TSquare] = princomp(B);
PC1=SCORE;
A1=PC1(:,1);
B1=PC1(:,2);
C1=PC1(:,3);
for ii=1:8
plot3(A1(ii,1),B1(ii,1),C1(ii,1),’r*’); hold on;
end
for ii=9:15
plot3(A(ii,1),B1(ii,1),C1(ii,1),’bo’); hold on;
end
for ii=16:25
plot3(A(ii,1),B1(ii,1),C1(ii,1),’g^’); hold on;
end
Regards
AmuthaHi
Following is the program I run for PCA. For the same set of data I tried PCA with various rotations in SPSS. But nothing gave the same plot as matlab did. Am I making any mistake in the program or why is the difference?
A=xlsread(‘sn30.xlsx’);A = A’;
[n m] = size(A);
AMean = mean(A);
AStd = std(A);
B = (A – repmat(AMean,[n 1])) ./ repmat(AStd,[n 1]);
[COEFF SCORE LATENT TSquare] = princomp(B);
PC1=SCORE;
A1=PC1(:,1);
B1=PC1(:,2);
C1=PC1(:,3);
for ii=1:8
plot3(A1(ii,1),B1(ii,1),C1(ii,1),’r*’); hold on;
end
for ii=9:15
plot3(A(ii,1),B1(ii,1),C1(ii,1),’bo’); hold on;
end
for ii=16:25
plot3(A(ii,1),B1(ii,1),C1(ii,1),’g^’); hold on;
end
Regards
Amutha Hi
Following is the program I run for PCA. For the same set of data I tried PCA with various rotations in SPSS. But nothing gave the same plot as matlab did. Am I making any mistake in the program or why is the difference?
A=xlsread(‘sn30.xlsx’);A = A’;
[n m] = size(A);
AMean = mean(A);
AStd = std(A);
B = (A – repmat(AMean,[n 1])) ./ repmat(AStd,[n 1]);
[COEFF SCORE LATENT TSquare] = princomp(B);
PC1=SCORE;
A1=PC1(:,1);
B1=PC1(:,2);
C1=PC1(:,3);
for ii=1:8
plot3(A1(ii,1),B1(ii,1),C1(ii,1),’r*’); hold on;
end
for ii=9:15
plot3(A(ii,1),B1(ii,1),C1(ii,1),’bo’); hold on;
end
for ii=16:25
plot3(A(ii,1),B1(ii,1),C1(ii,1),’g^’); hold on;
end
Regards
Amutha pca, spss MATLAB Answers — New Questions