SAS software has a procedure called "PROC PRINCOMP" for performing Principal Components Analysis. The eigenvalues and eigenvectors of the sample variance-covariance matrix can be computed. Eigenvalues are the variances of the principal components. Eigenvectors are the loadings of the principal components. The procedure can also create a new set of data that contains the values of the principal component scores. This new data can be used for later data analysis.
Here is an example of a SAS code to run a Principal Components Analysis.
*****
dm log 'clear';
dm output 'clear';
options nodate;
data PCA;
input X1 X2 X3 X4 X5 X6 X7 X8;
datalines;
6 7 2 5 8 7 8 8
9 10 5 8 10 9 9 10
7 8 3 6 9 8 9 7
5 6 8 5 6 5 9 2
6 8 8 8 4 4 9 5
7 7 7 6 8 7 10 5
9 9 8 8 8 8 8 8
9 9 9 8 9 9 8 8
9 9 7 8 8 8 8 5
4 7 10 2 10 10 7 10
4 7 10 0 10 8 3 9
4 7 10 4 10 10 7 8
6 9 8 10 5 4 9 4
8 9 8 9 6 3 8 2
4 8 8 7 5 4 10 2
6 9 5 7 8 9 8 9
8 7 7 7 9 5 8 6
6 8 8 4 8 8 6 4
6 7 8 4 7 8 5 4
4 8 7 8 8 9 10 5
;
PROC PRINCOMP DATA=PCA OUT=PCSCORES COVARIANCE;
VAR X1--X8;
title 'Principal Component Analysis';
RUN;
PROC FACTOR DATA=PCA scree;
VAR X1--X8;
TITLE2'Scree Plot of Eigenvalues';
RUN;
PROC PRINT DATA=PCSCORES;
VAR PRIN1 PRIN2 PRIN3;
TITLE2 'VALUES OF THE FIRST THREE PRINCIPAL COMPONENT SCORES';
RUN;
proc univariate data=pcscores plot;
var prin1 prin2;
TITLE2 'Univariate Analysis on the first two Principal Components';
run;
proc gplot DATA=PCSCORES;
plot prin2*prin1;
TITLE2 'A Scatter Plot of the First Two Principal Component Scores';
run;
quit;
*****
Acknowledgments goes to Weiming Ke, PhD (SDSU, Department of Mathematics and Statistics).
Labels: PhD blog
0 Comments:
<< Home